From c79afc05f851308057ab48fdcf8f0ddd7b0743ec Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Mon, 11 Nov 2024 10:22:46 +0000 Subject: [PATCH] Updating based on 5e6b1d3ca --- ...repostgresqllinkedservicetypeproperties.go | 17 +- .../model_mysqllinkedservicetypeproperties.go | 7 + ...repostgresqllinkedservicetypeproperties.go | 17 +- .../model_mysqllinkedservicetypeproperties.go | 7 + .../registrymanagement/model_acrdetails.go | 1 - .../model_storageaccountdetails.go | 1 - .../recoveryservices/2024-10-01/client.go | 100 ++ .../getprivatelinkresources/README.md | 36 + .../getprivatelinkresources/client.go | 26 + .../id_privatelinkresource.go | 139 +++ .../id_privatelinkresource_test.go | 327 ++++++ .../method_privatelinkresourcesget.go | 53 + .../model_privatelinkresource.go | 11 + .../model_privatelinkresourceproperties.go | 10 + .../getprivatelinkresources/version.go | 10 + .../listprivatelinkresources/README.md | 37 + .../listprivatelinkresources/client.go | 26 + .../listprivatelinkresources/id_vault.go | 130 +++ .../listprivatelinkresources/id_vault_test.go | 282 ++++++ .../method_privatelinkresourceslist.go | 105 ++ .../model_privatelinkresource.go | 11 + .../model_privatelinkresourceproperties.go | 10 + .../listprivatelinkresources/predicates.go | 27 + .../listprivatelinkresources/version.go | 10 + .../2024-10-01/recoveryservices/README.md | 62 ++ .../2024-10-01/recoveryservices/client.go | 26 + .../2024-10-01/recoveryservices/constants.go | 54 + .../recoveryservices/id_location.go | 121 +++ .../recoveryservices/id_location_test.go | 237 +++++ .../recoveryservices/id_providerlocation.go | 130 +++ .../id_providerlocation_test.go | 282 ++++++ .../recoveryservices/method_capabilities.go | 58 ++ .../method_checknameavailability.go | 58 ++ .../model_capabilitiesproperties.go} | 6 +- .../model_capabilitiesresponse.go | 9 + .../model_capabilitiesresponseproperties.go} | 6 +- .../model_checknameavailabilityparameters.go | 9 + .../model_checknameavailabilityresult.go | 10 + .../recoveryservices/model_dnszone.go | 8 + .../recoveryservices/model_dnszoneresponse.go | 9 + .../model_resourcecapabilities.go | 9 + .../2024-10-01/recoveryservices/version.go | 10 + .../2024-10-01/registeredidentities/client.go | 26 + .../id_registeredidentity.go | 139 +++ .../id_registeredidentity_test.go | 327 ++++++ .../registeredidentities/method_delete.go | 46 + .../registeredidentities/version.go | 10 + .../2024-10-01/replicationusages/README.md | 36 + .../2024-10-01/replicationusages/client.go | 26 + .../2024-10-01/replicationusages/id_vault.go | 130 +++ .../replicationusages/id_vault_test.go | 282 ++++++ .../replicationusages/method_list.go | 54 + .../replicationusages/model_jobssummary.go | 10 + .../model_monitoringsummary.go | 13 + .../model_replicationusage.go | 13 + .../model_replicationusagelist.go | 8 + .../2024-10-01/replicationusages/version.go | 10 + .../2024-10-01/vaultcertificates/README.md | 41 + .../2024-10-01/vaultcertificates/client.go | 26 + .../2024-10-01/vaultcertificates/constants.go | 60 ++ .../vaultcertificates/id_certificate.go | 139 +++ .../vaultcertificates/id_certificate_test.go | 327 ++++++ .../vaultcertificates/method_create.go | 57 ++ .../model_certificaterequest.go | 8 + .../model_rawcertificatedata.go | 9 + .../model_resourcecertificateandaaddetails.go | 99 ++ .../model_resourcecertificateandacsdetails.go | 95 ++ .../model_resourcecertificatedetails.go | 91 ++ .../model_vaultcertificateresponse.go | 48 + .../2024-10-01/vaultcertificates/version.go | 10 + .../2024-10-01/vaultextendedinfo/README.md | 78 ++ .../2024-10-01/vaultextendedinfo/client.go | 26 + .../2024-10-01/vaultextendedinfo/id_vault.go | 130 +++ .../vaultextendedinfo/id_vault_test.go | 282 ++++++ .../method_createorupdate.go | 58 ++ .../vaultextendedinfo/method_get.go | 54 + .../vaultextendedinfo/method_update.go | 58 ++ .../model_vaultextendedinfo.go | 11 + .../model_vaultextendedinforesource.go | 12 + .../2024-10-01/vaultextendedinfo/version.go | 10 + .../2024-10-01/vaults/README.md | 117 +++ .../2024-10-01/vaults/client.go | 26 + .../2024-10-01/vaults/constants.go | 958 ++++++++++++++++++ .../2024-10-01/vaults/id_vault.go | 130 +++ .../2024-10-01/vaults/id_vault_test.go | 282 ++++++ .../vaults/method_createorupdate.go | 104 ++ .../2024-10-01/vaults/method_delete.go | 70 ++ .../2024-10-01/vaults/method_get.go | 53 + .../vaults/method_listbyresourcegroup.go | 106 ++ .../vaults/method_listbysubscriptionid.go | 106 ++ .../2024-10-01/vaults/method_update.go | 104 ++ .../vaults/model_azuremonitoralertsettings.go | 10 + .../vaults/model_classicalertsettings.go | 9 + .../2024-10-01/vaults/model_cmkkekidentity.go | 9 + .../vaults/model_cmkkeyvaultproperties.go | 8 + .../model_crosssubscriptionrestoresettings.go | 8 + .../vaults/model_immutabilitysettings.go | 8 + .../vaults/model_monitoringsettings.go | 9 + .../2024-10-01/vaults/model_patchvault.go | 20 + .../vaults/model_privateendpoint.go | 8 + .../vaults/model_privateendpointconnection.go | 11 + ...rivateendpointconnectionvaultproperties.go | 12 + ...model_privatelinkserviceconnectionstate.go | 10 + .../vaults/model_restoresettings.go | 8 + .../vaults/model_securitysettings.go | 10 + .../2024-10-01/vaults/model_sku.go | 12 + .../vaults/model_softdeletesettings.go | 10 + .../2024-10-01/vaults/model_upgradedetails.go | 58 ++ .../2024-10-01/vaults/model_vault.go | 22 + .../vaults/model_vaultproperties.go | 24 + .../vaults/model_vaultpropertiesencryption.go | 10 + .../model_vaultpropertiesmovedetails.go | 42 + ...model_vaultpropertiesredundancysettings.go | 9 + .../2024-10-01/vaults/predicates.go | 37 + .../2024-10-01/vaults/version.go | 10 + .../2024-10-01/vaultusages/README.md | 36 + .../2024-10-01/vaultusages/client.go | 26 + .../2024-10-01/vaultusages/constants.go | 63 ++ .../2024-10-01/vaultusages/id_vault.go | 130 +++ .../2024-10-01/vaultusages/id_vault_test.go | 282 ++++++ .../vaultusages/method_usageslistbyvaults.go | 54 + .../2024-10-01/vaultusages/model_nameinfo.go | 9 + .../vaultusages/model_vaultusage.go | 31 + .../vaultusages/model_vaultusagelist.go | 8 + .../2024-10-01/vaultusages/version.go | 10 + .../2024-10-01/backupengines/README.md | 53 + .../2024-10-01/backupengines/client.go | 18 + .../2024-10-01/backupengines/constants.go | 88 ++ .../backupengines/id_backupengine.go | 139 +++ .../backupengines/id_backupengine_test.go | 327 ++++++ .../2024-10-01/backupengines/id_vault.go | 130 +++ .../2024-10-01/backupengines/id_vault_test.go | 282 ++++++ .../backupengines/method_get_autorest.go | 97 ++ .../backupengines/method_list_autorest.go | 215 ++++ .../model_azurebackupserverengine.go | 73 ++ .../backupengines/model_backupenginebase.go | 95 ++ .../model_backupenginebaseresource.go | 57 ++ .../model_backupengineextendedinfo.go | 33 + .../backupengines/model_dpmbackupengine.go | 73 ++ .../2024-10-01/backupengines/predicates.go | 37 + .../2024-10-01/backupengines/version.go | 10 + .../2024-10-01/backupjobs/README.md | 37 + .../2024-10-01/backupjobs/client.go | 18 + .../2024-10-01/backupjobs/constants.go | 225 ++++ .../2024-10-01/backupjobs/id_vault.go | 130 +++ .../2024-10-01/backupjobs/id_vault_test.go | 282 ++++++ .../backupjobs/method_list_autorest.go | 215 ++++ .../backupjobs/model_azureiaasvmerrorinfo.go | 11 + .../backupjobs/model_azureiaasvmjob.go | 97 ++ .../model_azureiaasvmjobextendedinfo.go | 13 + .../model_azureiaasvmjobtaskdetails.go | 45 + .../backupjobs/model_azureiaasvmjobv2.go | 96 ++ .../backupjobs/model_azurestorageerrorinfo.go | 10 + .../backupjobs/model_azurestoragejob.go | 97 ++ .../model_azurestoragejobextendedinfo.go | 10 + .../model_azurestoragejobtaskdetails.go | 9 + .../model_azureworkloaderrorinfo.go | 12 + .../backupjobs/model_azureworkloadjob.go | 95 ++ .../model_azureworkloadjobextendedinfo.go | 10 + .../model_azureworkloadjobtaskdetails.go | 9 + .../backupjobs/model_dpmerrorinfo.go | 9 + .../2024-10-01/backupjobs/model_dpmjob.go | 98 ++ .../backupjobs/model_dpmjobextendedinfo.go | 10 + .../backupjobs/model_dpmjobtaskdetails.go | 42 + .../2024-10-01/backupjobs/model_job.go | 130 +++ .../backupjobs/model_jobresource.go | 57 ++ .../backupjobs/model_maberrorinfo.go | 9 + .../2024-10-01/backupjobs/model_mabjob.go | 97 ++ .../backupjobs/model_mabjobextendedinfo.go | 10 + .../backupjobs/model_mabjobtaskdetails.go | 42 + .../2024-10-01/backupjobs/model_vaultjob.go | 94 ++ .../backupjobs/model_vaultjoberrorinfo.go | 10 + .../backupjobs/model_vaultjobextendedinfo.go | 8 + .../2024-10-01/backupjobs/predicates.go | 37 + .../2024-10-01/backupjobs/version.go | 10 + .../2024-10-01/backuppolicies/README.md | 37 + .../2024-10-01/backuppolicies/client.go | 18 + .../2024-10-01/backuppolicies/constants.go | 460 +++++++++ .../2024-10-01/backuppolicies/id_vault.go | 130 +++ .../backuppolicies/id_vault_test.go | 282 ++++++ .../backuppolicies/method_list_autorest.go | 215 ++++ .../model_azurefileshareprotectionpolicy.go | 104 ++ .../model_azureiaasvmprotectionpolicy.go | 113 +++ .../model_azuresqlprotectionpolicy.go | 86 ++ .../model_azurevmworkloadprotectionpolicy.go | 57 ++ .../model_dailyretentionformat.go | 8 + .../model_dailyretentionschedule.go | 9 + .../backuppolicies/model_dailyschedule.go | 8 + .../2024-10-01/backuppolicies/model_day.go | 9 + .../model_genericprotectionpolicy.go | 56 + .../backuppolicies/model_hourlyschedule.go | 28 + .../model_instantrpadditionaldetails.go | 9 + .../backuppolicies/model_logschedulepolicy.go | 50 + .../model_longtermretentionpolicy.go | 53 + .../model_longtermschedulepolicy.go | 49 + .../model_mabprotectionpolicy.go | 95 ++ .../model_monthlyretentionschedule.go | 12 + .../backuppolicies/model_protectionpolicy.go | 117 +++ .../model_protectionpolicyresource.go | 57 ++ .../backuppolicies/model_retentionduration.go | 9 + .../backuppolicies/model_retentionpolicy.go | 83 ++ .../backuppolicies/model_schedulepolicy.go | 99 ++ .../backuppolicies/model_settings.go | 10 + .../model_simpleretentionpolicy.go | 50 + .../model_simpleschedulepolicy.go | 54 + .../model_simpleschedulepolicyv2.go | 53 + .../model_snapshotbackupadditionaldetails.go | 10 + .../model_subprotectionpolicy.go | 57 ++ .../backuppolicies/model_tieringpolicy.go | 10 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + .../model_vaultretentionpolicy.go | 42 + .../model_weeklyretentionformat.go | 9 + .../model_weeklyretentionschedule.go | 10 + .../backuppolicies/model_weeklyschedule.go | 9 + .../model_yearlyretentionschedule.go | 13 + .../2024-10-01/backuppolicies/predicates.go | 37 + .../2024-10-01/backuppolicies/version.go | 10 + .../backupprotectableitems/README.md | 37 + .../backupprotectableitems/client.go | 18 + .../backupprotectableitems/constants.go | 107 ++ .../backupprotectableitems/id_vault.go | 130 +++ .../backupprotectableitems/id_vault_test.go | 282 ++++++ .../method_list_autorest.go | 215 ++++ .../model_azurefileshareprotectableitem.go | 60 ++ ...zureiaasclassiccomputevmprotectableitem.go | 60 ++ ...model_azureiaascomputevmprotectableitem.go | 60 ++ .../model_azurevmworkloadprotectableitem.go | 66 ++ ...revmworkloadsapasesystemprotectableitem.go | 66 ++ ...mworkloadsaphanadatabaseprotectableitem.go | 66 ++ .../model_azurevmworkloadsaphanadbinstance.go | 66 ++ ...zurevmworkloadsaphanahsrprotectableitem.go | 66 ++ ...evmworkloadsaphanasystemprotectableitem.go | 66 ++ ...loadsqlavailabilitygroupprotectableitem.go | 67 ++ ...urevmworkloadsqldatabaseprotectableitem.go | 66 ++ ...urevmworkloadsqlinstanceprotectableitem.go | 66 ++ .../model_distributednodesinfo.go | 11 + .../model_errordetail.go | 10 + .../model_iaasvmprotectableitem.go | 60 ++ .../model_prebackupvalidation.go | 10 + .../model_workloadprotectableitem.go | 175 ++++ .../model_workloadprotectableitemresource.go | 57 ++ .../backupprotectableitems/predicates.go | 37 + .../backupprotectableitems/version.go | 10 + .../2024-10-01/backupprotecteditems/README.md | 37 + .../2024-10-01/backupprotecteditems/client.go | 18 + .../backupprotecteditems/constants.go | 389 +++++++ .../backupprotecteditems/id_vault.go | 130 +++ .../backupprotecteditems/id_vault_test.go | 282 ++++++ .../method_list_autorest.go | 215 ++++ .../model_azurefileshareprotecteditem.go | 119 +++ ...azurefileshareprotecteditemextendedinfo.go | 42 + ..._azureiaasclassiccomputevmprotecteditem.go | 124 +++ .../model_azureiaascomputevmprotecteditem.go | 124 +++ .../model_azureiaasvmprotecteditem.go | 124 +++ ...el_azureiaasvmprotecteditemextendedinfo.go | 67 ++ .../model_azuresqlprotecteditem.go | 115 +++ ...model_azuresqlprotecteditemextendedinfo.go | 28 + .../model_azurevmworkloadprotecteditem.go | 126 +++ ...zurevmworkloadprotecteditemextendedinfo.go | 68 ++ ...revmworkloadsapasedatabaseprotecteditem.go | 126 +++ ...evmworkloadsaphanadatabaseprotecteditem.go | 126 +++ ...mworkloadsaphanadbinstanceprotecteditem.go | 126 +++ ...azurevmworkloadsqldatabaseprotecteditem.go | 126 +++ .../model_diskexclusionproperties.go | 9 + .../model_distributednodesinfo.go | 11 + .../model_dpmprotecteditem.go | 116 +++ .../model_dpmprotecteditemextendedinfo.go | 75 ++ .../backupprotecteditems/model_errordetail.go | 10 + .../model_extendedproperties.go | 9 + .../model_genericprotecteditem.go | 118 +++ .../model_kpiresourcehealthdetails.go | 9 + .../model_mabfilefolderprotecteditem.go | 119 +++ ..._mabfilefolderprotecteditemextendedinfo.go | 40 + .../model_protecteditem.go | 189 ++++ .../model_protecteditemresource.go | 57 ++ .../model_resourcehealthdetails.go | 11 + .../backupprotecteditems/predicates.go | 37 + .../backupprotecteditems/version.go | 10 + .../backupprotectioncontainers/README.md | 37 + .../backupprotectioncontainers/client.go | 18 + .../backupprotectioncontainers/constants.go | 332 ++++++ .../backupprotectioncontainers/id_vault.go | 130 +++ .../id_vault_test.go | 282 ++++++ .../method_list_autorest.go | 215 ++++ .../model_azurebackupservercontainer.go | 67 ++ ...odel_azureiaasclassiccomputevmcontainer.go | 62 ++ .../model_azureiaascomputevmcontainer.go | 62 ++ ...lagworkloadcontainerprotectioncontainer.go | 64 ++ .../model_azuresqlcontainer.go | 59 ++ .../model_azurestoragecontainer.go | 64 ++ ..._azurevmappcontainerprotectioncontainer.go | 64 ++ .../model_azureworkloadcontainer.go | 64 ++ ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 67 ++ .../model_dpmcontainerextendedinfo.go | 26 + .../model_errordetail.go | 10 + .../model_genericcontainer.go | 61 ++ .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 62 ++ .../model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 66 ++ .../model_mabcontainerextendedinfo.go | 30 + .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 168 +++ .../model_protectioncontainerresource.go | 57 ++ .../model_workloadinquirydetails.go | 10 + .../backupprotectioncontainers/predicates.go | 37 + .../backupprotectioncontainers/version.go | 10 + .../backupprotectionintent/README.md | 37 + .../backupprotectionintent/client.go | 18 + .../backupprotectionintent/constants.go | 180 ++++ .../backupprotectionintent/id_vault.go | 130 +++ .../backupprotectionintent/id_vault_test.go | 282 ++++++ .../method_list_autorest.go | 215 ++++ ...urerecoveryservicevaultprotectionintent.go | 59 ++ .../model_azureresourceprotectionintent.go | 60 ++ ...model_azureworkloadautoprotectionintent.go | 59 ++ ...reworkloadcontainerautoprotectionintent.go | 59 ++ ...el_azureworkloadsqlautoprotectionintent.go | 60 ++ .../model_protectionintent.go | 112 ++ .../model_protectionintentresource.go | 57 ++ .../backupprotectionintent/predicates.go | 37 + .../backupprotectionintent/version.go | 10 + .../backupresourceencryptionconfigs/README.md | 57 ++ .../backupresourceencryptionconfigs/client.go | 18 + .../constants.go | 116 +++ .../id_vault.go | 130 +++ .../id_vault_test.go | 282 ++++++ .../method_get_autorest.go | 69 ++ .../method_update_autorest.go | 68 ++ .../model_backupresourceencryptionconfig.go | 12 + ..._backupresourceencryptionconfigextended.go | 14 + ...esourceencryptionconfigextendedresource.go | 14 + ..._backupresourceencryptionconfigresource.go | 14 + .../version.go | 10 + .../README.md | 78 ++ .../client.go | 18 + .../constants.go | 138 +++ .../id_vault.go | 130 +++ .../id_vault_test.go | 282 ++++++ .../method_get_autorest.go | 69 ++ .../method_patch_autorest.go | 68 ++ .../method_update_autorest.go | 70 ++ .../model_backupresourceconfig.go | 13 + .../model_backupresourceconfigresource.go | 14 + .../version.go | 10 + .../backupresourcevaultconfigs/README.md | 78 ++ .../backupresourcevaultconfigs/client.go | 18 + .../backupresourcevaultconfigs/constants.go | 141 +++ .../backupresourcevaultconfigs/id_vault.go | 130 +++ .../id_vault_test.go | 282 ++++++ .../method_get_autorest.go | 69 ++ .../method_put_autorest.go | 99 ++ .../method_update_autorest.go | 99 ++ .../model_backupresourcevaultconfig.go | 15 + ...model_backupresourcevaultconfigresource.go | 14 + .../backupresourcevaultconfigs/version.go | 10 + .../2024-10-01/backups/README.md | 41 + .../2024-10-01/backups/client.go | 18 + .../2024-10-01/backups/constants.go | 54 + .../2024-10-01/backups/id_protecteditem.go | 157 +++ .../backups/id_protecteditem_test.go | 417 ++++++++ .../backups/method_trigger_autorest.go | 68 ++ .../model_azurefilesharebackuprequest.go | 50 + .../model_azureworkloadbackuprequest.go | 52 + .../2024-10-01/backups/model_backuprequest.go | 91 ++ .../backups/model_backuprequestresource.go | 57 ++ .../backups/model_iaasvmbackuprequest.go | 50 + .../2024-10-01/backups/version.go | 10 + .../2024-10-01/backupstatus/README.md | 41 + .../2024-10-01/backupstatus/client.go | 18 + .../2024-10-01/backupstatus/constants.go | 171 ++++ .../2024-10-01/backupstatus/id_location.go | 121 +++ .../backupstatus/id_location_test.go | 237 +++++ .../backupstatus/method_get_autorest.go | 70 ++ .../backupstatus/model_backupstatusrequest.go | 10 + .../model_backupstatusresponse.go | 18 + .../2024-10-01/backupstatus/version.go | 10 + .../2024-10-01/backupusagesummaries/README.md | 36 + .../2024-10-01/backupusagesummaries/client.go | 18 + .../backupusagesummaries/constants.go | 48 + .../backupusagesummaries/id_vault.go | 130 +++ .../backupusagesummaries/id_vault_test.go | 282 ++++++ .../method_list_autorest.go | 98 ++ .../model_backupmanagementusage.go | 31 + .../model_backupmanagementusagelist.go | 8 + .../backupusagesummaries/model_nameinfo.go | 9 + .../backupusagesummaries/version.go | 10 + .../2024-10-01/backupworkloaditems/README.md | 37 + .../2024-10-01/backupworkloaditems/client.go | 18 + .../backupworkloaditems/constants.go | 76 ++ .../id_protectioncontainer.go | 148 +++ .../id_protectioncontainer_test.go | 372 +++++++ .../method_list_autorest.go | 215 ++++ .../model_azurevmworkloaditem.go | 62 ++ ...urevmworkloadsapasedatabaseworkloaditem.go | 62 ++ ...azurevmworkloadsapasesystemworkloaditem.go | 62 ++ ...revmworkloadsaphanadatabaseworkloaditem.go | 62 ++ ...zurevmworkloadsaphanasystemworkloaditem.go | 62 ++ ..._azurevmworkloadsqldatabaseworkloaditem.go | 62 ++ ..._azurevmworkloadsqlinstanceworkloaditem.go | 63 ++ .../model_sqldatadirectory.go | 10 + .../backupworkloaditems/model_workloaditem.go | 127 +++ .../model_workloaditemresource.go | 57 ++ .../backupworkloaditems/predicates.go | 37 + .../2024-10-01/backupworkloaditems/version.go | 10 + .../2024-10-01/client.go | 239 +++++ .../2024-10-01/datamove/README.md | 54 + .../2024-10-01/datamove/client.go | 18 + .../2024-10-01/datamove/constants.go | 39 + .../2024-10-01/datamove/id_vault.go | 130 +++ .../2024-10-01/datamove/id_vault_test.go | 282 ++++++ .../method_bmspreparedatamove_autorest.go | 79 ++ .../method_bmstriggerdatamove_autorest.go | 79 ++ .../datamove/model_preparedatamoverequest.go | 12 + .../datamove/model_triggerdatamoverequest.go | 13 + .../2024-10-01/datamove/version.go | 10 + .../2024-10-01/featuresupport/README.md | 41 + .../2024-10-01/featuresupport/client.go | 18 + .../2024-10-01/featuresupport/constants.go | 45 + .../2024-10-01/featuresupport/id_location.go | 121 +++ .../featuresupport/id_location_test.go | 237 +++++ .../method_validate_autorest.go | 70 ++ ...el_azurebackupgoalfeaturesupportrequest.go | 49 + ...el_azurevmresourcefeaturesupportrequest.go | 51 + ...l_azurevmresourcefeaturesupportresponse.go | 8 + .../model_featuresupportrequest.go | 83 ++ .../2024-10-01/featuresupport/version.go | 10 + .../2024-10-01/fetchtieringcost/README.md | 37 + .../2024-10-01/fetchtieringcost/client.go | 18 + .../2024-10-01/fetchtieringcost/constants.go | 70 ++ .../2024-10-01/fetchtieringcost/id_vault.go | 130 +++ .../fetchtieringcost/id_vault_test.go | 282 ++++++ .../fetchtieringcost/method_post_autorest.go | 80 ++ ...tchtieringcostinfoforrehydrationrequest.go | 57 ++ .../model_fetchtieringcostinforequest.go | 101 ++ ...htieringcostsavingsinfoforpolicyrequest.go | 54 + ...gcostsavingsinfoforprotecteditemrequest.go | 55 + ...chtieringcostsavingsinfoforvaultrequest.go | 53 + .../fetchtieringcost/model_tieringcostinfo.go | 83 ++ .../model_tieringcostrehydrationinfo.go | 51 + .../model_tieringcostsavinginfo.go | 53 + .../2024-10-01/fetchtieringcost/version.go | 10 + .../itemlevelrecoveryconnections/README.md | 57 ++ .../itemlevelrecoveryconnections/client.go | 18 + .../id_recoverypoint.go | 166 +++ .../id_recoverypoint_test.go | 462 +++++++++ .../method_provision_autorest.go | 68 ++ .../method_revoke_autorest.go | 67 ++ ...model_azurefileshareprovisionilrrequest.go | 51 + .../model_iaasvmilrregistrationrequest.go | 53 + .../model_ilrrequest.go | 83 ++ .../model_ilrrequestresource.go | 57 ++ .../itemlevelrecoveryconnections/version.go | 10 + .../2024-10-01/jobcancellations/client.go | 18 + .../jobcancellations/id_backupjob.go | 139 +++ .../jobcancellations/id_backupjob_test.go | 327 ++++++ .../method_trigger_autorest.go | 67 ++ .../2024-10-01/jobcancellations/version.go | 10 + .../2024-10-01/jobdetails/README.md | 36 + .../2024-10-01/jobdetails/client.go | 18 + .../2024-10-01/jobdetails/constants.go | 225 ++++ .../2024-10-01/jobdetails/id_backupjob.go | 139 +++ .../jobdetails/id_backupjob_test.go | 327 ++++++ .../jobdetails/method_get_autorest.go | 68 ++ .../jobdetails/model_azureiaasvmerrorinfo.go | 11 + .../jobdetails/model_azureiaasvmjob.go | 97 ++ .../model_azureiaasvmjobextendedinfo.go | 13 + .../model_azureiaasvmjobtaskdetails.go | 45 + .../jobdetails/model_azureiaasvmjobv2.go | 96 ++ .../jobdetails/model_azurestorageerrorinfo.go | 10 + .../jobdetails/model_azurestoragejob.go | 97 ++ .../model_azurestoragejobextendedinfo.go | 10 + .../model_azurestoragejobtaskdetails.go | 9 + .../model_azureworkloaderrorinfo.go | 12 + .../jobdetails/model_azureworkloadjob.go | 95 ++ .../model_azureworkloadjobextendedinfo.go | 10 + .../model_azureworkloadjobtaskdetails.go | 9 + .../jobdetails/model_dpmerrorinfo.go | 9 + .../2024-10-01/jobdetails/model_dpmjob.go | 98 ++ .../jobdetails/model_dpmjobextendedinfo.go | 10 + .../jobdetails/model_dpmjobtaskdetails.go | 42 + .../2024-10-01/jobdetails/model_job.go | 130 +++ .../jobdetails/model_jobresource.go | 57 ++ .../jobdetails/model_maberrorinfo.go | 9 + .../2024-10-01/jobdetails/model_mabjob.go | 97 ++ .../jobdetails/model_mabjobextendedinfo.go | 10 + .../jobdetails/model_mabjobtaskdetails.go | 42 + .../2024-10-01/jobdetails/model_vaultjob.go | 94 ++ .../jobdetails/model_vaultjoberrorinfo.go | 10 + .../jobdetails/model_vaultjobextendedinfo.go | 8 + .../2024-10-01/jobdetails/version.go | 10 + .../2024-10-01/jobs/client.go | 18 + .../2024-10-01/jobs/id_vault.go | 130 +++ .../2024-10-01/jobs/id_vault_test.go | 282 ++++++ .../2024-10-01/jobs/method_export_autorest.go | 96 ++ .../2024-10-01/jobs/version.go | 10 + .../2024-10-01/operation/README.md | 41 + .../2024-10-01/operation/client.go | 18 + .../2024-10-01/operation/constants.go | 274 +++++ .../2024-10-01/operation/id_vault.go | 130 +++ .../2024-10-01/operation/id_vault_test.go | 282 ++++++ .../operation/method_validate_autorest.go | 70 ++ .../model_azurefilesharerestorerequest.go | 57 ++ ..._azureworkloadpointintimerestorerequest.go | 61 ++ .../model_azureworkloadrestorerequest.go | 60 ++ ...orkloadsaphanapointintimerestorerequest.go | 61 ++ ...apointintimerestorewithrehydraterequest.go | 62 ++ ...odel_azureworkloadsaphanarestorerequest.go | 60 ++ ...kloadsaphanarestorewithrehydraterequest.go | 61 ++ ...ureworkloadsqlpointintimerestorerequest.go | 64 ++ ...lpointintimerestorewithrehydraterequest.go | 65 ++ .../model_azureworkloadsqlrestorerequest.go | 63 ++ ...eworkloadsqlrestorewithrehydraterequest.go | 64 ++ .../operation/model_encryptiondetails.go | 12 + .../2024-10-01/operation/model_errordetail.go | 10 + .../operation/model_extendedlocation.go | 9 + .../operation/model_iaasvmrestorerequest.go | 76 ++ ...del_iaasvmrestorewithrehydrationrequest.go | 77 ++ .../model_identitybasedrestoredetails.go | 9 + .../operation/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../operation/model_restorefilespecs.go | 10 + .../operation/model_restorerequest.go | 172 ++++ .../operation/model_securedvmdetails.go | 8 + .../model_snapshotrestoreparameters.go | 9 + .../model_sqldatadirectorymapping.go | 11 + .../operation/model_targetafsrestoreinfo.go | 9 + .../model_targetdisknetworkaccesssettings.go | 9 + .../operation/model_targetrestoreinfo.go | 11 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + ...l_validateiaasvmrestoreoperationrequest.go | 78 ++ .../model_validateoperationrequest.go | 83 ++ .../model_validateoperationrequestresource.go | 42 + .../model_validateoperationresponse.go | 8 + .../model_validateoperationsresponse.go | 8 + .../model_validaterestoreoperationrequest.go | 78 ++ .../2024-10-01/operation/version.go | 10 + .../privateendpointconnection/README.md | 65 ++ .../privateendpointconnection/client.go | 18 + .../privateendpointconnection/constants.go | 107 ++ .../id_privateendpointconnection.go | 139 +++ .../id_privateendpointconnection_test.go | 327 ++++++ .../method_delete_autorest.go | 78 ++ .../method_get_autorest.go | 68 ++ .../method_put_autorest.go | 80 ++ .../model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 11 + ...model_privateendpointconnectionresource.go | 14 + ...model_privatelinkserviceconnectionstate.go | 10 + .../privateendpointconnection/version.go | 10 + .../protectablecontainers/README.md | 37 + .../protectablecontainers/client.go | 18 + .../protectablecontainers/constants.go | 133 +++ .../protectablecontainers/id_backupfabric.go | 139 +++ .../id_backupfabric_test.go | 327 ++++++ .../method_list_autorest.go | 215 ++++ .../model_azurestorageprotectablecontainer.go | 57 ++ ...azurevmappcontainerprotectablecontainer.go | 57 ++ .../model_protectablecontainer.go | 87 ++ .../model_protectablecontainerresource.go | 57 ++ .../protectablecontainers/predicates.go | 37 + .../protectablecontainers/version.go | 10 + .../2024-10-01/protecteditems/README.md | 73 ++ .../2024-10-01/protecteditems/client.go | 18 + .../2024-10-01/protecteditems/constants.go | 389 +++++++ .../protecteditems/id_protecteditem.go | 157 +++ .../protecteditems/id_protecteditem_test.go | 417 ++++++++ .../method_createorupdate_autorest.go | 98 ++ .../protecteditems/method_delete_autorest.go | 66 ++ .../protecteditems/method_get_autorest.go | 97 ++ .../model_azurefileshareprotecteditem.go | 119 +++ ...azurefileshareprotecteditemextendedinfo.go | 42 + ..._azureiaasclassiccomputevmprotecteditem.go | 124 +++ .../model_azureiaascomputevmprotecteditem.go | 124 +++ .../model_azureiaasvmprotecteditem.go | 124 +++ ...el_azureiaasvmprotecteditemextendedinfo.go | 67 ++ .../model_azuresqlprotecteditem.go | 115 +++ ...model_azuresqlprotecteditemextendedinfo.go | 28 + .../model_azurevmworkloadprotecteditem.go | 126 +++ ...zurevmworkloadprotecteditemextendedinfo.go | 68 ++ ...revmworkloadsapasedatabaseprotecteditem.go | 126 +++ ...evmworkloadsaphanadatabaseprotecteditem.go | 126 +++ ...mworkloadsaphanadbinstanceprotecteditem.go | 126 +++ ...azurevmworkloadsqldatabaseprotecteditem.go | 126 +++ .../model_diskexclusionproperties.go | 9 + .../model_distributednodesinfo.go | 11 + .../protecteditems/model_dpmprotecteditem.go | 116 +++ .../model_dpmprotecteditemextendedinfo.go | 75 ++ .../protecteditems/model_errordetail.go | 10 + .../model_extendedproperties.go | 9 + .../model_genericprotecteditem.go | 118 +++ .../model_kpiresourcehealthdetails.go | 9 + .../model_mabfilefolderprotecteditem.go | 119 +++ ..._mabfilefolderprotecteditemextendedinfo.go | 40 + .../protecteditems/model_protecteditem.go | 189 ++++ .../model_protecteditemresource.go | 57 ++ .../model_resourcehealthdetails.go | 11 + .../2024-10-01/protecteditems/version.go | 10 + .../2024-10-01/protectioncontainers/README.md | 101 ++ .../2024-10-01/protectioncontainers/client.go | 18 + .../protectioncontainers/constants.go | 332 ++++++ .../protectioncontainers/id_backupfabric.go | 139 +++ .../id_backupfabric_test.go | 327 ++++++ .../id_protectioncontainer.go | 148 +++ .../id_protectioncontainer_test.go | 372 +++++++ .../method_get_autorest.go | 68 ++ .../method_inquire_autorest.go | 96 ++ .../method_refresh_autorest.go | 96 ++ .../method_register_autorest.go | 80 ++ .../method_unregister_autorest.go | 66 ++ .../model_azurebackupservercontainer.go | 67 ++ ...odel_azureiaasclassiccomputevmcontainer.go | 62 ++ .../model_azureiaascomputevmcontainer.go | 62 ++ ...lagworkloadcontainerprotectioncontainer.go | 64 ++ .../model_azuresqlcontainer.go | 59 ++ .../model_azurestoragecontainer.go | 64 ++ ..._azurevmappcontainerprotectioncontainer.go | 64 ++ .../model_azureworkloadcontainer.go | 64 ++ ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 67 ++ .../model_dpmcontainerextendedinfo.go | 26 + .../protectioncontainers/model_errordetail.go | 10 + .../model_genericcontainer.go | 61 ++ .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 62 ++ .../protectioncontainers/model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 66 ++ .../model_mabcontainerextendedinfo.go | 30 + .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 168 +++ .../model_protectioncontainerresource.go | 57 ++ .../model_workloadinquirydetails.go | 10 + .../protectioncontainers/version.go | 10 + .../2024-10-01/protectionintent/README.md | 94 ++ .../2024-10-01/protectionintent/client.go | 18 + .../2024-10-01/protectionintent/constants.go | 281 +++++ .../id_backupprotectionintent.go | 148 +++ .../id_backupprotectionintent_test.go | 372 +++++++ .../protectionintent/id_location.go | 121 +++ .../protectionintent/id_location_test.go | 237 +++++ .../method_createorupdate_autorest.go | 69 ++ .../method_delete_autorest.go | 66 ++ .../protectionintent/method_get_autorest.go | 68 ++ .../method_validate_autorest.go | 70 ++ ...urerecoveryservicevaultprotectionintent.go | 59 ++ .../model_azureresourceprotectionintent.go | 60 ++ ...model_azureworkloadautoprotectionintent.go | 59 ++ ...reworkloadcontainerautoprotectionintent.go | 59 ++ ...el_azureworkloadsqlautoprotectionintent.go | 60 ++ .../model_prevalidateenablebackuprequest.go | 11 + .../model_prevalidateenablebackupresponse.go | 13 + .../model_protectionintent.go | 112 ++ .../model_protectionintentresource.go | 57 ++ .../2024-10-01/protectionintent/version.go | 10 + .../2024-10-01/protectionpolicies/README.md | 69 ++ .../2024-10-01/protectionpolicies/client.go | 18 + .../protectionpolicies/constants.go | 460 +++++++++ .../protectionpolicies/id_backuppolicy.go | 139 +++ .../id_backuppolicy_test.go | 327 ++++++ .../method_createorupdate_autorest.go | 98 ++ .../method_delete_autorest.go | 78 ++ .../protectionpolicies/method_get_autorest.go | 68 ++ .../model_azurefileshareprotectionpolicy.go | 104 ++ .../model_azureiaasvmprotectionpolicy.go | 113 +++ .../model_azuresqlprotectionpolicy.go | 86 ++ .../model_azurevmworkloadprotectionpolicy.go | 57 ++ .../model_dailyretentionformat.go | 8 + .../model_dailyretentionschedule.go | 9 + .../protectionpolicies/model_dailyschedule.go | 8 + .../protectionpolicies/model_day.go | 9 + .../model_genericprotectionpolicy.go | 56 + .../model_hourlyschedule.go | 28 + .../model_instantrpadditionaldetails.go | 9 + .../model_logschedulepolicy.go | 50 + .../model_longtermretentionpolicy.go | 53 + .../model_longtermschedulepolicy.go | 49 + .../model_mabprotectionpolicy.go | 95 ++ .../model_monthlyretentionschedule.go | 12 + .../model_protectionpolicy.go | 117 +++ .../model_protectionpolicyresource.go | 57 ++ .../model_retentionduration.go | 9 + .../model_retentionpolicy.go | 83 ++ .../model_schedulepolicy.go | 99 ++ .../protectionpolicies/model_settings.go | 10 + .../model_simpleretentionpolicy.go | 50 + .../model_simpleschedulepolicy.go | 54 + .../model_simpleschedulepolicyv2.go | 53 + .../model_snapshotbackupadditionaldetails.go | 10 + .../model_subprotectionpolicy.go | 57 ++ .../protectionpolicies/model_tieringpolicy.go | 10 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + .../model_vaultretentionpolicy.go | 42 + .../model_weeklyretentionformat.go | 9 + .../model_weeklyretentionschedule.go | 10 + .../model_weeklyschedule.go | 9 + .../model_yearlyretentionschedule.go | 13 + .../2024-10-01/protectionpolicies/version.go | 10 + .../2024-10-01/recoverypoint/README.md | 37 + .../2024-10-01/recoverypoint/client.go | 18 + .../2024-10-01/recoverypoint/constants.go | 42 + .../recoverypoint/id_recoverypoint.go | 166 +++ .../recoverypoint/id_recoverypoint_test.go | 462 +++++++++ .../method_moverecoverypoint_autorest.go | 79 ++ .../model_moverpacrosstiersrequest.go | 10 + .../2024-10-01/recoverypoint/version.go | 10 + .../2024-10-01/recoverypoints/README.md | 53 + .../2024-10-01/recoverypoints/client.go | 18 + .../2024-10-01/recoverypoints/constants.go | 153 +++ .../recoverypoints/id_protecteditem.go | 157 +++ .../recoverypoints/id_protecteditem_test.go | 417 ++++++++ .../recoverypoints/id_recoverypoint.go | 166 +++ .../recoverypoints/id_recoverypoint_test.go | 462 +++++++++ .../recoverypoints/method_get_autorest.go | 68 ++ .../recoverypoints/method_list_autorest.go | 215 ++++ .../model_azurefilesharerecoverypoint.go | 54 + ...l_azureworkloadpointintimerecoverypoint.go | 55 + .../model_azureworkloadrecoverypoint.go | 54 + ...workloadsaphanapointintimerecoverypoint.go | 55 + ...model_azureworkloadsaphanarecoverypoint.go | 54 + ...zureworkloadsqlpointintimerecoverypoint.go | 56 + .../model_azureworkloadsqlrecoverypoint.go | 55 + ...ureworkloadsqlrecoverypointextendedinfo.go | 27 + .../recoverypoints/model_bekdetails.go | 10 + .../recoverypoints/model_diskinformation.go | 9 + .../recoverypoints/model_extendedlocation.go | 9 + .../model_genericrecoverypoint.go | 54 + .../model_iaasvmrecoverypoint.go | 70 ++ .../recoverypoints/model_kekdetails.go | 10 + .../model_keyandsecretdetails.go | 10 + .../recoverypoints/model_pointintimerange.go | 39 + .../recoverypoints/model_recoverypoint.go | 139 +++ .../model_recoverypointdiskconfiguration.go | 11 + .../model_recoverypointmovereadinessinfo.go | 9 + .../model_recoverypointproperties.go | 10 + .../model_recoverypointresource.go | 57 ++ .../model_recoverypointtierinformationv2.go | 10 + .../recoverypoints/model_sqldatadirectory.go | 10 + .../2024-10-01/recoverypoints/predicates.go | 37 + .../2024-10-01/recoverypoints/version.go | 10 + .../README.md | 42 + .../client.go | 18 + .../constants.go | 153 +++ .../id_protecteditem.go | 157 +++ .../id_protecteditem_test.go | 417 ++++++++ .../method_list_autorest.go | 187 ++++ .../model_azurefilesharerecoverypoint.go | 54 + ...l_azureworkloadpointintimerecoverypoint.go | 55 + .../model_azureworkloadrecoverypoint.go | 54 + ...workloadsaphanapointintimerecoverypoint.go | 55 + ...model_azureworkloadsaphanarecoverypoint.go | 54 + ...zureworkloadsqlpointintimerecoverypoint.go | 56 + .../model_azureworkloadsqlrecoverypoint.go | 55 + ...ureworkloadsqlrecoverypointextendedinfo.go | 27 + .../model_bekdetails.go | 10 + .../model_diskinformation.go | 9 + .../model_extendedlocation.go | 9 + .../model_genericrecoverypoint.go | 54 + .../model_iaasvmrecoverypoint.go | 70 ++ .../model_kekdetails.go | 10 + .../model_keyandsecretdetails.go | 10 + ...recoverypointsrecommendedformoverequest.go | 9 + .../model_pointintimerange.go | 39 + .../model_recoverypoint.go | 139 +++ .../model_recoverypointdiskconfiguration.go | 11 + .../model_recoverypointmovereadinessinfo.go | 9 + .../model_recoverypointproperties.go | 10 + .../model_recoverypointresource.go | 57 ++ .../model_recoverypointtierinformationv2.go | 10 + .../model_sqldatadirectory.go | 10 + .../predicates.go | 37 + .../version.go | 10 + .../2024-10-01/resourceguardproxies/README.md | 37 + .../2024-10-01/resourceguardproxies/client.go | 18 + .../resourceguardproxies/id_vault.go | 130 +++ .../resourceguardproxies/id_vault_test.go | 282 ++++++ .../method_get_autorest.go | 186 ++++ .../model_resourceguardoperationdetail.go | 9 + .../model_resourceguardproxybase.go | 11 + .../model_resourceguardproxybaseresource.go | 14 + .../resourceguardproxies/predicates.go | 37 + .../resourceguardproxies/version.go | 10 + .../2024-10-01/resourceguardproxy/README.md | 94 ++ .../2024-10-01/resourceguardproxy/client.go | 18 + .../id_backupresourceguardproxy.go | 139 +++ .../id_backupresourceguardproxy_test.go | 327 ++++++ .../method_delete_autorest.go | 66 ++ .../resourceguardproxy/method_get_autorest.go | 68 ++ .../resourceguardproxy/method_put_autorest.go | 69 ++ .../method_unlockdelete_autorest.go | 70 ++ .../model_resourceguardoperationdetail.go | 9 + .../model_resourceguardproxybase.go | 11 + .../model_resourceguardproxybaseresource.go | 14 + .../model_unlockdeleterequest.go | 9 + .../model_unlockdeleteresponse.go | 8 + .../2024-10-01/resourceguardproxy/version.go | 10 + .../2024-10-01/restores/README.md | 37 + .../2024-10-01/restores/client.go | 18 + .../2024-10-01/restores/constants.go | 274 +++++ .../2024-10-01/restores/id_recoverypoint.go | 166 +++ .../restores/id_recoverypoint_test.go | 462 +++++++++ .../restores/method_trigger_autorest.go | 108 ++ .../model_azurefilesharerestorerequest.go | 57 ++ ..._azureworkloadpointintimerestorerequest.go | 61 ++ .../model_azureworkloadrestorerequest.go | 60 ++ ...orkloadsaphanapointintimerestorerequest.go | 61 ++ ...apointintimerestorewithrehydraterequest.go | 62 ++ ...odel_azureworkloadsaphanarestorerequest.go | 60 ++ ...kloadsaphanarestorewithrehydraterequest.go | 61 ++ ...ureworkloadsqlpointintimerestorerequest.go | 64 ++ ...lpointintimerestorewithrehydraterequest.go | 65 ++ .../model_azureworkloadsqlrestorerequest.go | 63 ++ ...eworkloadsqlrestorewithrehydraterequest.go | 64 ++ .../restores/model_encryptiondetails.go | 12 + .../restores/model_extendedlocation.go | 9 + .../restores/model_iaasvmrestorerequest.go | 76 ++ ...del_iaasvmrestorewithrehydrationrequest.go | 77 ++ .../model_identitybasedrestoredetails.go | 9 + .../2024-10-01/restores/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../restores/model_restorefilespecs.go | 10 + .../restores/model_restorerequest.go | 172 ++++ .../restores/model_restorerequestresource.go | 57 ++ .../restores/model_securedvmdetails.go | 8 + .../model_snapshotrestoreparameters.go | 9 + .../restores/model_sqldatadirectorymapping.go | 11 + .../restores/model_targetafsrestoreinfo.go | 9 + .../model_targetdisknetworkaccesssettings.go | 9 + .../restores/model_targetrestoreinfo.go | 11 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + .../2024-10-01/restores/version.go | 10 + .../2024-10-01/securitypins/README.md | 41 + .../2024-10-01/securitypins/client.go | 18 + .../2024-10-01/securitypins/id_vault.go | 130 +++ .../2024-10-01/securitypins/id_vault_test.go | 282 ++++++ .../securitypins/method_get_autorest.go | 99 ++ .../securitypins/model_securitypinbase.go | 8 + .../securitypins/model_tokeninformation.go | 10 + .../2024-10-01/securitypins/version.go | 10 + .../softdeletedcontainers/README.md | 37 + .../softdeletedcontainers/client.go | 18 + .../softdeletedcontainers/constants.go | 332 ++++++ .../softdeletedcontainers/id_vault.go | 130 +++ .../softdeletedcontainers/id_vault_test.go | 282 ++++++ ...eletedprotectioncontainerslist_autorest.go | 215 ++++ .../model_azurebackupservercontainer.go | 67 ++ ...odel_azureiaasclassiccomputevmcontainer.go | 62 ++ .../model_azureiaascomputevmcontainer.go | 62 ++ ...lagworkloadcontainerprotectioncontainer.go | 64 ++ .../model_azuresqlcontainer.go | 59 ++ .../model_azurestoragecontainer.go | 64 ++ ..._azurevmappcontainerprotectioncontainer.go | 64 ++ .../model_azureworkloadcontainer.go | 64 ++ ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 67 ++ .../model_dpmcontainerextendedinfo.go | 26 + .../model_errordetail.go | 10 + .../model_genericcontainer.go | 61 ++ .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 62 ++ .../model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 66 ++ .../model_mabcontainerextendedinfo.go | 30 + .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 168 +++ .../model_protectioncontainerresource.go | 57 ++ .../model_workloadinquirydetails.go | 10 + .../softdeletedcontainers/predicates.go | 37 + .../softdeletedcontainers/version.go | 10 + .../2024-10-01/validateoperation/README.md | 37 + .../2024-10-01/validateoperation/client.go | 18 + .../2024-10-01/validateoperation/constants.go | 274 +++++ .../2024-10-01/validateoperation/id_vault.go | 130 +++ .../validateoperation/id_vault_test.go | 282 ++++++ .../method_trigger_autorest.go | 79 ++ .../model_azurefilesharerestorerequest.go | 57 ++ ..._azureworkloadpointintimerestorerequest.go | 61 ++ .../model_azureworkloadrestorerequest.go | 60 ++ ...orkloadsaphanapointintimerestorerequest.go | 61 ++ ...apointintimerestorewithrehydraterequest.go | 62 ++ ...odel_azureworkloadsaphanarestorerequest.go | 60 ++ ...kloadsaphanarestorewithrehydraterequest.go | 61 ++ ...ureworkloadsqlpointintimerestorerequest.go | 64 ++ ...lpointintimerestorewithrehydraterequest.go | 65 ++ .../model_azureworkloadsqlrestorerequest.go | 63 ++ ...eworkloadsqlrestorewithrehydraterequest.go | 64 ++ .../model_encryptiondetails.go | 12 + .../model_extendedlocation.go | 9 + .../model_iaasvmrestorerequest.go | 76 ++ ...del_iaasvmrestorewithrehydrationrequest.go | 77 ++ .../model_identitybasedrestoredetails.go | 9 + .../validateoperation/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../model_restorefilespecs.go | 10 + .../validateoperation/model_restorerequest.go | 172 ++++ .../model_securedvmdetails.go | 8 + .../model_snapshotrestoreparameters.go | 9 + .../model_sqldatadirectorymapping.go | 11 + .../model_targetafsrestoreinfo.go | 9 + .../model_targetdisknetworkaccesssettings.go | 9 + .../model_targetrestoreinfo.go | 11 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + ...l_validateiaasvmrestoreoperationrequest.go | 78 ++ .../model_validateoperationrequest.go | 83 ++ .../model_validateoperationrequestresource.go | 42 + .../model_validaterestoreoperationrequest.go | 78 ++ .../2024-10-01/validateoperation/version.go | 10 + 921 files changed, 67288 insertions(+), 14 deletions(-) create mode 100644 resource-manager/recoveryservices/2024-10-01/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/README.md create mode 100644 resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/id_privatelinkresource.go create mode 100644 resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/id_privatelinkresource_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/method_privatelinkresourcesget.go create mode 100644 resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/model_privatelinkresource.go create mode 100644 resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/model_privatelinkresourceproperties.go create mode 100644 resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/version.go create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/README.md create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/method_privatelinkresourceslist.go create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/model_privatelinkresource.go create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/model_privatelinkresourceproperties.go create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/predicates.go create mode 100644 resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/version.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/README.md create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/constants.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/id_location.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/id_location_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/id_providerlocation.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/id_providerlocation_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/method_capabilities.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/method_checknameavailability.go rename resource-manager/{machinelearningservices/2024-04-01/registrymanagement/model_usercreatedacraccount.go => recoveryservices/2024-10-01/recoveryservices/model_capabilitiesproperties.go} (55%) create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesresponse.go rename resource-manager/{machinelearningservices/2024-04-01/registrymanagement/model_usercreatedstorageaccount.go => recoveryservices/2024-10-01/recoveryservices/model_capabilitiesresponseproperties.go} (55%) create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/model_checknameavailabilityparameters.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/model_checknameavailabilityresult.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/model_dnszone.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/model_dnszoneresponse.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/model_resourcecapabilities.go create mode 100644 resource-manager/recoveryservices/2024-10-01/recoveryservices/version.go create mode 100644 resource-manager/recoveryservices/2024-10-01/registeredidentities/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/registeredidentities/id_registeredidentity.go create mode 100644 resource-manager/recoveryservices/2024-10-01/registeredidentities/id_registeredidentity_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/registeredidentities/method_delete.go create mode 100644 resource-manager/recoveryservices/2024-10-01/registeredidentities/version.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/README.md create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/method_list.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/model_jobssummary.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/model_monitoringsummary.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/model_replicationusage.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/model_replicationusagelist.go create mode 100644 resource-manager/recoveryservices/2024-10-01/replicationusages/version.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/README.md create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/constants.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/id_certificate.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/id_certificate_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/method_create.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_certificaterequest.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_rawcertificatedata.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificateandaaddetails.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificateandacsdetails.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificatedetails.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_vaultcertificateresponse.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultcertificates/version.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/README.md create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_createorupdate.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_get.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_update.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/model_vaultextendedinfo.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/model_vaultextendedinforesource.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/version.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/README.md create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/constants.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/method_createorupdate.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/method_delete.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/method_get.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/method_listbyresourcegroup.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/method_listbysubscriptionid.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/method_update.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_azuremonitoralertsettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_classicalertsettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_cmkkekidentity.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_cmkkeyvaultproperties.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_crosssubscriptionrestoresettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_immutabilitysettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_monitoringsettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_patchvault.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpoint.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpointconnection.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpointconnectionvaultproperties.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_restoresettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_securitysettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_sku.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_softdeletesettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_upgradedetails.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_vault.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_vaultproperties.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesencryption.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesmovedetails.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesredundancysettings.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/predicates.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaults/version.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/README.md create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/client.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/constants.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/method_usageslistbyvaults.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/model_nameinfo.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/model_vaultusage.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/model_vaultusagelist.go create mode 100644 resource-manager/recoveryservices/2024-10-01/vaultusages/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_backupengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_backupengine_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_azurebackupserverengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupenginebase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupenginebaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupengineextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_dpmbackupengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupengines/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestorageerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloaderrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_job.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_jobresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_maberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjoberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azurefileshareprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azureiaasvmprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azuresqlprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_day.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_genericprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_hourlyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_instantrpadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_logschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_longtermretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_longtermschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_mabprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_monthlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_protectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_protectionpolicyresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_retentionduration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_retentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_schedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_settings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleschedulepolicyv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_snapshotbackupadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_subprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_tieringpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_vaultretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_yearlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurefileshareprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_iaasvmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_prebackupvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_workloadprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_workloadprotectableitemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurefileshareprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasvmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azuresqlprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_diskexclusionproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_dpmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_extendedproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_genericprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_kpiresourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_mabfilefolderprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_protecteditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_resourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureresourceprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_protectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_protectionintentresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/model_azurefilesharebackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/model_azureworkloadbackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/model_backuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/model_backuprequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/model_iaasvmbackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backups/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/model_backupstatusrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/model_backupstatusresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_backupmanagementusage.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_backupmanagementusagelist.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_nameinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/id_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/id_protectioncontainer_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_workloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_workloaditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/method_bmspreparedatamove_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/method_bmstriggerdatamove_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/model_preparedatamoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/model_triggerdatamoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/datamove/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_featuresupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/method_post_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostinforequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostsavinginfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/method_provision_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/method_revoke_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_ilrrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_ilrrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/id_backupjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/id_backupjob_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/id_backupjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/id_backupjob_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestorageerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloaderrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_job.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_jobresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_maberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjoberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobs/method_export_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/jobs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateiaasvmrestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationsresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validaterestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/operation/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/id_privateendpointconnection.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/id_privateendpointconnection_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpointconnection.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpointconnectionresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/id_backupfabric.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/id_backupfabric_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_azurestorageprotectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_protectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_protectablecontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurefileshareprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaascomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasvmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azuresqlprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_diskexclusionproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_dpmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_dpmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_extendedproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_genericprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_kpiresourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_mabfilefolderprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_protecteditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_resourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_backupfabric.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_backupfabric_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_protectioncontainer_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_inquire_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_refresh_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_register_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_unregister_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_backupprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_backupprotectionintent_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureresourceprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_prevalidateenablebackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_prevalidateenablebackupresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_protectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_protectionintentresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/id_backuppolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/id_backuppolicy_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azurefileshareprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azuresqlprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_day.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_genericprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_hourlyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_instantrpadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_logschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_longtermretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_longtermschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_mabprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_monthlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_protectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_protectionpolicyresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_retentionduration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_retentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_schedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_settings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleschedulepolicyv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_snapshotbackupadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_subprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_tieringpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_vaultretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_yearlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/method_moverecoverypoint_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/model_moverpacrosstiersrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azurefilesharerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_bekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_diskinformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_genericrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_iaasvmrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_kekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_keyandsecretdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_pointintimerange.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointdiskconfiguration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointmovereadinessinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointtierinformationv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_bekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_diskinformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_kekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_pointintimerange.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardoperationdetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardproxybase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardproxybaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/id_backupresourceguardproxy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/id_backupresourceguardproxy_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_unlockdelete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardoperationdetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardproxybase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardproxybaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_unlockdeleterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_unlockdeleteresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorerequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/restores/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/securitypins/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/securitypins/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/securitypins/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/securitypins/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/securitypins/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/securitypins/model_securitypinbase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/securitypins/model_tokeninformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/securitypins/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateoperationrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validaterestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/version.go diff --git a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_azurepostgresqllinkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_azurepostgresqllinkedservicetypeproperties.go index dcf9c0d964a..e0dcd44df44 100644 --- a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_azurepostgresqllinkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_azurepostgresqllinkedservicetypeproperties.go @@ -4,7 +4,18 @@ package dataflowdebugsession // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AzurePostgreSqlLinkedServiceTypeProperties struct { - ConnectionString *string `json:"connectionString,omitempty"` - EncryptedCredential *string `json:"encryptedCredential,omitempty"` - Password *AzureKeyVaultSecretReference `json:"password,omitempty"` + CommandTimeout *int64 `json:"commandTimeout,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + Database *string `json:"database,omitempty"` + Encoding *string `json:"encoding,omitempty"` + EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Password *AzureKeyVaultSecretReference `json:"password,omitempty"` + Port *int64 `json:"port,omitempty"` + ReadBufferSize *int64 `json:"readBufferSize,omitempty"` + Server *string `json:"server,omitempty"` + SslMode *int64 `json:"sslMode,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` + Timezone *string `json:"timezone,omitempty"` + TrustServerCertificate *bool `json:"trustServerCertificate,omitempty"` + Username *string `json:"username,omitempty"` } diff --git a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_mysqllinkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_mysqllinkedservicetypeproperties.go index fcedf4c6c1e..9fd5d482bce 100644 --- a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_mysqllinkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_mysqllinkedservicetypeproperties.go @@ -4,14 +4,21 @@ package dataflowdebugsession // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type MySqlLinkedServiceTypeProperties struct { + AllowZeroDateTime *bool `json:"allowZeroDateTime,omitempty"` ConnectionString *string `json:"connectionString,omitempty"` + ConnectionTimeout *int64 `json:"connectionTimeout,omitempty"` + ConvertZeroDateTime *bool `json:"convertZeroDateTime,omitempty"` Database *string `json:"database,omitempty"` DriverVersion *string `json:"driverVersion,omitempty"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + GuidFormat *string `json:"guidFormat,omitempty"` Password *AzureKeyVaultSecretReference `json:"password,omitempty"` Port *int64 `json:"port,omitempty"` Server *string `json:"server,omitempty"` + SslCert *string `json:"sslCert,omitempty"` + SslKey *string `json:"sslKey,omitempty"` SslMode *int64 `json:"sslMode,omitempty"` + TreatTinyAsBoolean *bool `json:"treatTinyAsBoolean,omitempty"` UseSystemTrustStore *int64 `json:"useSystemTrustStore,omitempty"` Username *string `json:"username,omitempty"` } diff --git a/resource-manager/datafactory/2018-06-01/linkedservices/model_azurepostgresqllinkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/linkedservices/model_azurepostgresqllinkedservicetypeproperties.go index 5ae3b01761d..c2cab794548 100644 --- a/resource-manager/datafactory/2018-06-01/linkedservices/model_azurepostgresqllinkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/linkedservices/model_azurepostgresqllinkedservicetypeproperties.go @@ -4,7 +4,18 @@ package linkedservices // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AzurePostgreSqlLinkedServiceTypeProperties struct { - ConnectionString *string `json:"connectionString,omitempty"` - EncryptedCredential *string `json:"encryptedCredential,omitempty"` - Password *AzureKeyVaultSecretReference `json:"password,omitempty"` + CommandTimeout *int64 `json:"commandTimeout,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + Database *string `json:"database,omitempty"` + Encoding *string `json:"encoding,omitempty"` + EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Password *AzureKeyVaultSecretReference `json:"password,omitempty"` + Port *int64 `json:"port,omitempty"` + ReadBufferSize *int64 `json:"readBufferSize,omitempty"` + Server *string `json:"server,omitempty"` + SslMode *int64 `json:"sslMode,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` + Timezone *string `json:"timezone,omitempty"` + TrustServerCertificate *bool `json:"trustServerCertificate,omitempty"` + Username *string `json:"username,omitempty"` } diff --git a/resource-manager/datafactory/2018-06-01/linkedservices/model_mysqllinkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/linkedservices/model_mysqllinkedservicetypeproperties.go index b4a7fc56d5a..4f4cee07108 100644 --- a/resource-manager/datafactory/2018-06-01/linkedservices/model_mysqllinkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/linkedservices/model_mysqllinkedservicetypeproperties.go @@ -4,14 +4,21 @@ package linkedservices // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type MySqlLinkedServiceTypeProperties struct { + AllowZeroDateTime *bool `json:"allowZeroDateTime,omitempty"` ConnectionString *string `json:"connectionString,omitempty"` + ConnectionTimeout *int64 `json:"connectionTimeout,omitempty"` + ConvertZeroDateTime *bool `json:"convertZeroDateTime,omitempty"` Database *string `json:"database,omitempty"` DriverVersion *string `json:"driverVersion,omitempty"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + GuidFormat *string `json:"guidFormat,omitempty"` Password *AzureKeyVaultSecretReference `json:"password,omitempty"` Port *int64 `json:"port,omitempty"` Server *string `json:"server,omitempty"` + SslCert *string `json:"sslCert,omitempty"` + SslKey *string `json:"sslKey,omitempty"` SslMode *int64 `json:"sslMode,omitempty"` + TreatTinyAsBoolean *bool `json:"treatTinyAsBoolean,omitempty"` UseSystemTrustStore *int64 `json:"useSystemTrustStore,omitempty"` Username *string `json:"username,omitempty"` } diff --git a/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_acrdetails.go b/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_acrdetails.go index 39a0122248e..3c33f4c6008 100644 --- a/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_acrdetails.go +++ b/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_acrdetails.go @@ -5,5 +5,4 @@ package registrymanagement type AcrDetails struct { SystemCreatedAcrAccount *SystemCreatedAcrAccount `json:"systemCreatedAcrAccount,omitempty"` - UserCreatedAcrAccount *UserCreatedAcrAccount `json:"userCreatedAcrAccount,omitempty"` } diff --git a/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_storageaccountdetails.go b/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_storageaccountdetails.go index dd836303b19..a727790a017 100644 --- a/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_storageaccountdetails.go +++ b/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_storageaccountdetails.go @@ -5,5 +5,4 @@ package registrymanagement type StorageAccountDetails struct { SystemCreatedStorageAccount *SystemCreatedStorageAccount `json:"systemCreatedStorageAccount,omitempty"` - UserCreatedStorageAccount *UserCreatedStorageAccount `json:"userCreatedStorageAccount,omitempty"` } diff --git a/resource-manager/recoveryservices/2024-10-01/client.go b/resource-manager/recoveryservices/2024-10-01/client.go new file mode 100644 index 00000000000..bae70363f06 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/client.go @@ -0,0 +1,100 @@ +package v2024_10_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/recoveryservices" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/registeredidentities" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/replicationusages" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaultcertificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaults" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaultusages" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + GetPrivateLinkResources *getprivatelinkresources.GetPrivateLinkResourcesClient + ListPrivateLinkResources *listprivatelinkresources.ListPrivateLinkResourcesClient + RecoveryServices *recoveryservices.RecoveryServicesClient + RegisteredIdentities *registeredidentities.RegisteredIdentitiesClient + ReplicationUsages *replicationusages.ReplicationUsagesClient + VaultCertificates *vaultcertificates.VaultCertificatesClient + VaultExtendedInfo *vaultextendedinfo.VaultExtendedInfoClient + VaultUsages *vaultusages.VaultUsagesClient + Vaults *vaults.VaultsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + getPrivateLinkResourcesClient, err := getprivatelinkresources.NewGetPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building GetPrivateLinkResources client: %+v", err) + } + configureFunc(getPrivateLinkResourcesClient.Client) + + listPrivateLinkResourcesClient, err := listprivatelinkresources.NewListPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ListPrivateLinkResources client: %+v", err) + } + configureFunc(listPrivateLinkResourcesClient.Client) + + recoveryServicesClient, err := recoveryservices.NewRecoveryServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RecoveryServices client: %+v", err) + } + configureFunc(recoveryServicesClient.Client) + + registeredIdentitiesClient, err := registeredidentities.NewRegisteredIdentitiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RegisteredIdentities client: %+v", err) + } + configureFunc(registeredIdentitiesClient.Client) + + replicationUsagesClient, err := replicationusages.NewReplicationUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationUsages client: %+v", err) + } + configureFunc(replicationUsagesClient.Client) + + vaultCertificatesClient, err := vaultcertificates.NewVaultCertificatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VaultCertificates client: %+v", err) + } + configureFunc(vaultCertificatesClient.Client) + + vaultExtendedInfoClient, err := vaultextendedinfo.NewVaultExtendedInfoClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VaultExtendedInfo client: %+v", err) + } + configureFunc(vaultExtendedInfoClient.Client) + + vaultUsagesClient, err := vaultusages.NewVaultUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VaultUsages client: %+v", err) + } + configureFunc(vaultUsagesClient.Client) + + vaultsClient, err := vaults.NewVaultsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Vaults client: %+v", err) + } + configureFunc(vaultsClient.Client) + + return &Client{ + GetPrivateLinkResources: getPrivateLinkResourcesClient, + ListPrivateLinkResources: listPrivateLinkResourcesClient, + RecoveryServices: recoveryServicesClient, + RegisteredIdentities: registeredIdentitiesClient, + ReplicationUsages: replicationUsagesClient, + VaultCertificates: vaultCertificatesClient, + VaultExtendedInfo: vaultExtendedInfoClient, + VaultUsages: vaultUsagesClient, + Vaults: vaultsClient, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/README.md b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/README.md new file mode 100644 index 00000000000..5cb7ee69fc1 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources` Documentation + +The `getprivatelinkresources` SDK allows for interaction with Azure Resource Manager `recoveryservices` (API Version `2024-10-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/recoveryservices/2024-10-01/getprivatelinkresources" +``` + + +### Client Initialization + +```go +client := getprivatelinkresources.NewGetPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GetPrivateLinkResourcesClient.PrivateLinkResourcesGet` + +```go +ctx := context.TODO() +id := getprivatelinkresources.NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "privateLinkResourceName") + +read, err := client.PrivateLinkResourcesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/client.go b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/client.go new file mode 100644 index 00000000000..1257c24a86f --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/client.go @@ -0,0 +1,26 @@ +package getprivatelinkresources + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewGetPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*GetPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "getprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GetPrivateLinkResourcesClient: %+v", err) + } + + return &GetPrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/id_privatelinkresource.go b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/id_privatelinkresource.go new file mode 100644 index 00000000000..71c766b3995 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/id_privatelinkresource.go @@ -0,0 +1,139 @@ +package getprivatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + PrivateLinkResourceName string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, vaultName string, privateLinkResourceName string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + PrivateLinkResourceName: privateLinkResourceName, + } +} + +// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId +func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateLinkResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.PrivateLinkResourceName, ok = input.Parsed["privateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateLinkResourceName", input) + } + + return nil +} + +// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID +func ValidatePrivateLinkResourceID(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 := ParsePrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Link Resource ID +func (id PrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.PrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID +func (id PrivateLinkResourceId) 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", "vaultName"), + resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), + resourceids.UserSpecifiedSegment("privateLinkResourceName", "privateLinkResourceName"), + } +} + +// String returns a human-readable description of this Private Link Resource ID +func (id PrivateLinkResourceId) 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("Private Link Resource Name: %q", id.PrivateLinkResourceName), + } + return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/id_privatelinkresource_test.go b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/id_privatelinkresource_test.go new file mode 100644 index 00000000000..caf0c30cc64 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/id_privatelinkresource_test.go @@ -0,0 +1,327 @@ +package getprivatelinkresources + +import ( + "testing" + + "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 = &PrivateLinkResourceId{} + +func TestNewPrivateLinkResourceID(t *testing.T) { + id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "privateLinkResourceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.PrivateLinkResourceName != "privateLinkResourceName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateLinkResourceName'", id.PrivateLinkResourceName, "privateLinkResourceName") + } +} + +func TestFormatPrivateLinkResourceID(t *testing.T) { + actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "privateLinkResourceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateLinkResources/privateLinkResourceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateLinkResources/privateLinkResourceName", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + PrivateLinkResourceName: "privateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateLinkResources/privateLinkResourceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateLinkResources/privateLinkResourceName", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + PrivateLinkResourceName: "privateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateLinkResources/privateLinkResourceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeNaMe", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + PrivateLinkResourceName: "pRiVaTeLiNkReSoUrCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestSegmentsForPrivateLinkResourceId(t *testing.T) { + segments := PrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/method_privatelinkresourcesget.go b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/method_privatelinkresourcesget.go new file mode 100644 index 00000000000..d9320826b8d --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/method_privatelinkresourcesget.go @@ -0,0 +1,53 @@ +package getprivatelinkresources + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// PrivateLinkResourcesGet ... +func (c GetPrivateLinkResourcesClient) PrivateLinkResourcesGet(ctx context.Context, id PrivateLinkResourceId) (result PrivateLinkResourcesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/model_privatelinkresource.go b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..36e56a45b5e --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package getprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..92b1276283a --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package getprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/version.go b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/version.go new file mode 100644 index 00000000000..c7114ab5afa --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/getprivatelinkresources/version.go @@ -0,0 +1,10 @@ +package getprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/getprivatelinkresources/2024-10-01" +} diff --git a/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/README.md b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/README.md new file mode 100644 index 00000000000..e33eccfb777 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources` Documentation + +The `listprivatelinkresources` SDK allows for interaction with Azure Resource Manager `recoveryservices` (API Version `2024-10-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/recoveryservices/2024-10-01/listprivatelinkresources" +``` + + +### Client Initialization + +```go +client := listprivatelinkresources.NewListPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ListPrivateLinkResourcesClient.PrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := listprivatelinkresources.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.PrivateLinkResourcesList(ctx, id)` can be used to do batched pagination +items, err := client.PrivateLinkResourcesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/client.go b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/client.go new file mode 100644 index 00000000000..0e4c4d9c12a --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/client.go @@ -0,0 +1,26 @@ +package listprivatelinkresources + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewListPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*ListPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "listprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ListPrivateLinkResourcesClient: %+v", err) + } + + return &ListPrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/id_vault.go b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/id_vault.go new file mode 100644 index 00000000000..1c5208ff20c --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/id_vault.go @@ -0,0 +1,130 @@ +package listprivatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/id_vault_test.go b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/id_vault_test.go new file mode 100644 index 00000000000..8e3ced17c0b --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/id_vault_test.go @@ -0,0 +1,282 @@ +package listprivatelinkresources + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/method_privatelinkresourceslist.go b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/method_privatelinkresourceslist.go new file mode 100644 index 00000000000..9ae98e274df --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/method_privatelinkresourceslist.go @@ -0,0 +1,105 @@ +package listprivatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type PrivateLinkResourcesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +type PrivateLinkResourcesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PrivateLinkResourcesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PrivateLinkResourcesList ... +func (c ListPrivateLinkResourcesClient) PrivateLinkResourcesList(ctx context.Context, id VaultId) (result PrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PrivateLinkResourcesListCustomPager{}, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PrivateLinkResourcesListComplete retrieves all the results into a single object +func (c ListPrivateLinkResourcesClient) PrivateLinkResourcesListComplete(ctx context.Context, id VaultId) (PrivateLinkResourcesListCompleteResult, error) { + return c.PrivateLinkResourcesListCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// PrivateLinkResourcesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ListPrivateLinkResourcesClient) PrivateLinkResourcesListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate PrivateLinkResourceOperationPredicate) (result PrivateLinkResourcesListCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.PrivateLinkResourcesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PrivateLinkResourcesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/model_privatelinkresource.go b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..43ad3ab77fa --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package listprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..b1ff4a935fd --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package listprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/predicates.go b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/predicates.go new file mode 100644 index 00000000000..5eb0bb91e57 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/predicates.go @@ -0,0 +1,27 @@ +package listprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateLinkResourceOperationPredicate) Matches(input PrivateLinkResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + 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/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/version.go b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/version.go new file mode 100644 index 00000000000..5c45802e79c --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/listprivatelinkresources/version.go @@ -0,0 +1,10 @@ +package listprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/listprivatelinkresources/2024-10-01" +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/README.md b/resource-manager/recoveryservices/2024-10-01/recoveryservices/README.md new file mode 100644 index 00000000000..b67e146e4ce --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/README.md @@ -0,0 +1,62 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/recoveryservices` Documentation + +The `recoveryservices` SDK allows for interaction with Azure Resource Manager `recoveryservices` (API Version `2024-10-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/recoveryservices/2024-10-01/recoveryservices" +``` + + +### Client Initialization + +```go +client := recoveryservices.NewRecoveryServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryServicesClient.Capabilities` + +```go +ctx := context.TODO() +id := recoveryservices.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := recoveryservices.ResourceCapabilities{ + // ... +} + + +read, err := client.Capabilities(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecoveryServicesClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := recoveryservices.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + +payload := recoveryservices.CheckNameAvailabilityParameters{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/client.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/client.go new file mode 100644 index 00000000000..3e7dcf4ddd2 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/client.go @@ -0,0 +1,26 @@ +package recoveryservices + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryServicesClient struct { + Client *resourcemanager.Client +} + +func NewRecoveryServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*RecoveryServicesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "recoveryservices", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecoveryServicesClient: %+v", err) + } + + return &RecoveryServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/constants.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/constants.go new file mode 100644 index 00000000000..920bcd8e566 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/constants.go @@ -0,0 +1,54 @@ +package recoveryservices + +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 VaultSubResourceType string + +const ( + VaultSubResourceTypeAzureBackup VaultSubResourceType = "AzureBackup" + VaultSubResourceTypeAzureBackupSecondary VaultSubResourceType = "AzureBackup_secondary" + VaultSubResourceTypeAzureSiteRecovery VaultSubResourceType = "AzureSiteRecovery" +) + +func PossibleValuesForVaultSubResourceType() []string { + return []string{ + string(VaultSubResourceTypeAzureBackup), + string(VaultSubResourceTypeAzureBackupSecondary), + string(VaultSubResourceTypeAzureSiteRecovery), + } +} + +func (s *VaultSubResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultSubResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVaultSubResourceType(input string) (*VaultSubResourceType, error) { + vals := map[string]VaultSubResourceType{ + "azurebackup": VaultSubResourceTypeAzureBackup, + "azurebackup_secondary": VaultSubResourceTypeAzureBackupSecondary, + "azuresiterecovery": VaultSubResourceTypeAzureSiteRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultSubResourceType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_location.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_location.go new file mode 100644 index 00000000000..7645cd13836 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_location.go @@ -0,0 +1,121 @@ +package recoveryservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_location_test.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_location_test.go new file mode 100644 index 00000000000..e92c1cbef04 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_location_test.go @@ -0,0 +1,237 @@ +package recoveryservices + +import ( + "testing" + + "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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_providerlocation.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_providerlocation.go new file mode 100644 index 00000000000..8efce5381e6 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_providerlocation.go @@ -0,0 +1,130 @@ +package recoveryservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(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 := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) 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("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_providerlocation_test.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_providerlocation_test.go new file mode 100644 index 00000000000..79e606728bf --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package recoveryservices + +import ( + "testing" + + "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 = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/method_capabilities.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/method_capabilities.go new file mode 100644 index 00000000000..5dd5a520fca --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/method_capabilities.go @@ -0,0 +1,58 @@ +package recoveryservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapabilitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CapabilitiesResponse +} + +// Capabilities ... +func (c RecoveryServicesClient) Capabilities(ctx context.Context, id LocationId, input ResourceCapabilities) (result CapabilitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/capabilities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CapabilitiesResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/method_checknameavailability.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/method_checknameavailability.go new file mode 100644 index 00000000000..3347af0ccac --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/method_checknameavailability.go @@ -0,0 +1,58 @@ +package recoveryservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c RecoveryServicesClient) CheckNameAvailability(ctx context.Context, id ProviderLocationId, input CheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CheckNameAvailabilityResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_usercreatedacraccount.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesproperties.go similarity index 55% rename from resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_usercreatedacraccount.go rename to resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesproperties.go index 08c31c6f6b5..3698ddb8850 100644 --- a/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_usercreatedacraccount.go +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesproperties.go @@ -1,8 +1,8 @@ -package registrymanagement +package recoveryservices // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type UserCreatedAcrAccount struct { - ArmResourceId *ArmResourceId `json:"armResourceId,omitempty"` +type CapabilitiesProperties struct { + DnsZones *[]DNSZone `json:"dnsZones,omitempty"` } diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesresponse.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesresponse.go new file mode 100644 index 00000000000..47e4997660f --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesresponse.go @@ -0,0 +1,9 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapabilitiesResponse struct { + Properties *CapabilitiesResponseProperties `json:"properties,omitempty"` + Type string `json:"type"` +} diff --git a/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_usercreatedstorageaccount.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesresponseproperties.go similarity index 55% rename from resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_usercreatedstorageaccount.go rename to resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesresponseproperties.go index 125bdb3488b..8c1bfbcac8d 100644 --- a/resource-manager/machinelearningservices/2024-04-01/registrymanagement/model_usercreatedstorageaccount.go +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_capabilitiesresponseproperties.go @@ -1,8 +1,8 @@ -package registrymanagement +package recoveryservices // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type UserCreatedStorageAccount struct { - ArmResourceId *ArmResourceId `json:"armResourceId,omitempty"` +type CapabilitiesResponseProperties struct { + DnsZones *[]DNSZoneResponse `json:"dnsZones,omitempty"` } diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_checknameavailabilityparameters.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_checknameavailabilityparameters.go new file mode 100644 index 00000000000..e6c5aff2402 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_checknameavailabilityparameters.go @@ -0,0 +1,9 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityParameters struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_checknameavailabilityresult.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_checknameavailabilityresult.go new file mode 100644 index 00000000000..d2840ec335e --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_checknameavailabilityresult.go @@ -0,0 +1,10 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResult struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_dnszone.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_dnszone.go new file mode 100644 index 00000000000..34952cfbd7e --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_dnszone.go @@ -0,0 +1,8 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DNSZone struct { + SubResource *VaultSubResourceType `json:"subResource,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_dnszoneresponse.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_dnszoneresponse.go new file mode 100644 index 00000000000..4aabe0bd6d4 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_dnszoneresponse.go @@ -0,0 +1,9 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DNSZoneResponse struct { + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` + SubResource *VaultSubResourceType `json:"subResource,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_resourcecapabilities.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_resourcecapabilities.go new file mode 100644 index 00000000000..16d3a668058 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/model_resourcecapabilities.go @@ -0,0 +1,9 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceCapabilities struct { + Properties *CapabilitiesProperties `json:"properties,omitempty"` + Type string `json:"type"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/recoveryservices/version.go b/resource-manager/recoveryservices/2024-10-01/recoveryservices/version.go new file mode 100644 index 00000000000..8a48ab73752 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/recoveryservices/version.go @@ -0,0 +1,10 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/recoveryservices/2024-10-01" +} diff --git a/resource-manager/recoveryservices/2024-10-01/registeredidentities/client.go b/resource-manager/recoveryservices/2024-10-01/registeredidentities/client.go new file mode 100644 index 00000000000..14617f2815f --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/registeredidentities/client.go @@ -0,0 +1,26 @@ +package registeredidentities + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisteredIdentitiesClient struct { + Client *resourcemanager.Client +} + +func NewRegisteredIdentitiesClientWithBaseURI(sdkApi sdkEnv.Api) (*RegisteredIdentitiesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "registeredidentities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RegisteredIdentitiesClient: %+v", err) + } + + return &RegisteredIdentitiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/registeredidentities/id_registeredidentity.go b/resource-manager/recoveryservices/2024-10-01/registeredidentities/id_registeredidentity.go new file mode 100644 index 00000000000..596e7ee5850 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/registeredidentities/id_registeredidentity.go @@ -0,0 +1,139 @@ +package registeredidentities + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RegisteredIdentityId{}) +} + +var _ resourceids.ResourceId = &RegisteredIdentityId{} + +// RegisteredIdentityId is a struct representing the Resource ID for a Registered Identity +type RegisteredIdentityId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + RegisteredIdentityName string +} + +// NewRegisteredIdentityID returns a new RegisteredIdentityId struct +func NewRegisteredIdentityID(subscriptionId string, resourceGroupName string, vaultName string, registeredIdentityName string) RegisteredIdentityId { + return RegisteredIdentityId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + RegisteredIdentityName: registeredIdentityName, + } +} + +// ParseRegisteredIdentityID parses 'input' into a RegisteredIdentityId +func ParseRegisteredIdentityID(input string) (*RegisteredIdentityId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegisteredIdentityId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegisteredIdentityId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegisteredIdentityIDInsensitively parses 'input' case-insensitively into a RegisteredIdentityId +// note: this method should only be used for API response data and not user input +func ParseRegisteredIdentityIDInsensitively(input string) (*RegisteredIdentityId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegisteredIdentityId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegisteredIdentityId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegisteredIdentityId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.RegisteredIdentityName, ok = input.Parsed["registeredIdentityName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registeredIdentityName", input) + } + + return nil +} + +// ValidateRegisteredIdentityID checks that 'input' can be parsed as a Registered Identity ID +func ValidateRegisteredIdentityID(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 := ParseRegisteredIdentityID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registered Identity ID +func (id RegisteredIdentityId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/registeredIdentities/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.RegisteredIdentityName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registered Identity ID +func (id RegisteredIdentityId) 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", "vaultName"), + resourceids.StaticSegment("staticRegisteredIdentities", "registeredIdentities", "registeredIdentities"), + resourceids.UserSpecifiedSegment("registeredIdentityName", "registeredIdentityName"), + } +} + +// String returns a human-readable description of this Registered Identity ID +func (id RegisteredIdentityId) 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("Registered Identity Name: %q", id.RegisteredIdentityName), + } + return fmt.Sprintf("Registered Identity (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-10-01/registeredidentities/id_registeredidentity_test.go b/resource-manager/recoveryservices/2024-10-01/registeredidentities/id_registeredidentity_test.go new file mode 100644 index 00000000000..0ad33ee16df --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/registeredidentities/id_registeredidentity_test.go @@ -0,0 +1,327 @@ +package registeredidentities + +import ( + "testing" + + "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 = &RegisteredIdentityId{} + +func TestNewRegisteredIdentityID(t *testing.T) { + id := NewRegisteredIdentityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "registeredIdentityName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.RegisteredIdentityName != "registeredIdentityName" { + t.Fatalf("Expected %q but got %q for Segment 'RegisteredIdentityName'", id.RegisteredIdentityName, "registeredIdentityName") + } +} + +func TestFormatRegisteredIdentityID(t *testing.T) { + actual := NewRegisteredIdentityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "registeredIdentityName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/registeredIdentities/registeredIdentityName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegisteredIdentityID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegisteredIdentityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/registeredIdentities", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/registeredIdentities/registeredIdentityName", + Expected: &RegisteredIdentityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + RegisteredIdentityName: "registeredIdentityName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/registeredIdentities/registeredIdentityName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegisteredIdentityID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.RegisteredIdentityName != v.Expected.RegisteredIdentityName { + t.Fatalf("Expected %q but got %q for RegisteredIdentityName", v.Expected.RegisteredIdentityName, actual.RegisteredIdentityName) + } + + } +} + +func TestParseRegisteredIdentityIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegisteredIdentityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/registeredIdentities", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEgIsTeReDiDeNtItIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/registeredIdentities/registeredIdentityName", + Expected: &RegisteredIdentityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + RegisteredIdentityName: "registeredIdentityName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/registeredIdentities/registeredIdentityName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEgIsTeReDiDeNtItIeS/rEgIsTeReDiDeNtItYnAmE", + Expected: &RegisteredIdentityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + RegisteredIdentityName: "rEgIsTeReDiDeNtItYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEgIsTeReDiDeNtItIeS/rEgIsTeReDiDeNtItYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegisteredIdentityIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.RegisteredIdentityName != v.Expected.RegisteredIdentityName { + t.Fatalf("Expected %q but got %q for RegisteredIdentityName", v.Expected.RegisteredIdentityName, actual.RegisteredIdentityName) + } + + } +} + +func TestSegmentsForRegisteredIdentityId(t *testing.T) { + segments := RegisteredIdentityId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegisteredIdentityId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/registeredidentities/method_delete.go b/resource-manager/recoveryservices/2024-10-01/registeredidentities/method_delete.go new file mode 100644 index 00000000000..16a5301af92 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/registeredidentities/method_delete.go @@ -0,0 +1,46 @@ +package registeredidentities + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData +} + +// Delete ... +func (c RegisteredIdentitiesClient) Delete(ctx context.Context, id RegisteredIdentityId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/registeredidentities/version.go b/resource-manager/recoveryservices/2024-10-01/registeredidentities/version.go new file mode 100644 index 00000000000..c29a0d61994 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/registeredidentities/version.go @@ -0,0 +1,10 @@ +package registeredidentities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/registeredidentities/2024-10-01" +} diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/README.md b/resource-manager/recoveryservices/2024-10-01/replicationusages/README.md new file mode 100644 index 00000000000..e0f2529ad85 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/replicationusages` Documentation + +The `replicationusages` SDK allows for interaction with Azure Resource Manager `recoveryservices` (API Version `2024-10-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/recoveryservices/2024-10-01/replicationusages" +``` + + +### Client Initialization + +```go +client := replicationusages.NewReplicationUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationUsagesClient.List` + +```go +ctx := context.TODO() +id := replicationusages.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/client.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/client.go new file mode 100644 index 00000000000..42ad2679a29 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/client.go @@ -0,0 +1,26 @@ +package replicationusages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationUsagesClient struct { + Client *resourcemanager.Client +} + +func NewReplicationUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationUsagesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationusages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationUsagesClient: %+v", err) + } + + return &ReplicationUsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/id_vault.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/id_vault.go new file mode 100644 index 00000000000..d36d08b75c1 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/id_vault.go @@ -0,0 +1,130 @@ +package replicationusages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservices/2024-10-01/replicationusages/id_vault_test.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/id_vault_test.go new file mode 100644 index 00000000000..ac57fd5e1da --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationusages + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/method_list.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/method_list.go new file mode 100644 index 00000000000..cbb2387c540 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/method_list.go @@ -0,0 +1,54 @@ +package replicationusages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *ReplicationUsageList +} + +// List ... +func (c ReplicationUsagesClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationUsages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ReplicationUsageList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/model_jobssummary.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/model_jobssummary.go new file mode 100644 index 00000000000..b4e8997b7d2 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/model_jobssummary.go @@ -0,0 +1,10 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobsSummary struct { + FailedJobs *int64 `json:"failedJobs,omitempty"` + InProgressJobs *int64 `json:"inProgressJobs,omitempty"` + SuspendedJobs *int64 `json:"suspendedJobs,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/model_monitoringsummary.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/model_monitoringsummary.go new file mode 100644 index 00000000000..fbf4ba89507 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/model_monitoringsummary.go @@ -0,0 +1,13 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoringSummary struct { + DeprecatedProviderCount *int64 `json:"deprecatedProviderCount,omitempty"` + EventsCount *int64 `json:"eventsCount,omitempty"` + SupportedProviderCount *int64 `json:"supportedProviderCount,omitempty"` + UnHealthyProviderCount *int64 `json:"unHealthyProviderCount,omitempty"` + UnHealthyVMCount *int64 `json:"unHealthyVmCount,omitempty"` + UnsupportedProviderCount *int64 `json:"unsupportedProviderCount,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/model_replicationusage.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/model_replicationusage.go new file mode 100644 index 00000000000..0842f810533 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/model_replicationusage.go @@ -0,0 +1,13 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationUsage struct { + JobsSummary *JobsSummary `json:"jobsSummary,omitempty"` + MonitoringSummary *MonitoringSummary `json:"monitoringSummary,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + RecoveryPlanCount *int64 `json:"recoveryPlanCount,omitempty"` + RecoveryServicesProviderAuthType *int64 `json:"recoveryServicesProviderAuthType,omitempty"` + RegisteredServersCount *int64 `json:"registeredServersCount,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/model_replicationusagelist.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/model_replicationusagelist.go new file mode 100644 index 00000000000..11300c459d2 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/model_replicationusagelist.go @@ -0,0 +1,8 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationUsageList struct { + Value *[]ReplicationUsage `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/replicationusages/version.go b/resource-manager/recoveryservices/2024-10-01/replicationusages/version.go new file mode 100644 index 00000000000..df7be55ad75 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/replicationusages/version.go @@ -0,0 +1,10 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationusages/2024-10-01" +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/README.md b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/README.md new file mode 100644 index 00000000000..291b6e6f90f --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaultcertificates` Documentation + +The `vaultcertificates` SDK allows for interaction with Azure Resource Manager `recoveryservices` (API Version `2024-10-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/recoveryservices/2024-10-01/vaultcertificates" +``` + + +### Client Initialization + +```go +client := vaultcertificates.NewVaultCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VaultCertificatesClient.Create` + +```go +ctx := context.TODO() +id := vaultcertificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "certificateName") + +payload := vaultcertificates.CertificateRequest{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/client.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/client.go new file mode 100644 index 00000000000..99ba23915ba --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/client.go @@ -0,0 +1,26 @@ +package vaultcertificates + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultCertificatesClient struct { + Client *resourcemanager.Client +} + +func NewVaultCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultCertificatesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vaultcertificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultCertificatesClient: %+v", err) + } + + return &VaultCertificatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/constants.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/constants.go new file mode 100644 index 00000000000..66072e83ada --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/constants.go @@ -0,0 +1,60 @@ +package vaultcertificates + +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 AuthType string + +const ( + AuthTypeAAD AuthType = "AAD" + AuthTypeACS AuthType = "ACS" + AuthTypeAccessControlService AuthType = "AccessControlService" + AuthTypeAzureActiveDirectory AuthType = "AzureActiveDirectory" + AuthTypeInvalid AuthType = "Invalid" +) + +func PossibleValuesForAuthType() []string { + return []string{ + string(AuthTypeAAD), + string(AuthTypeACS), + string(AuthTypeAccessControlService), + string(AuthTypeAzureActiveDirectory), + string(AuthTypeInvalid), + } +} + +func (s *AuthType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthType(input string) (*AuthType, error) { + vals := map[string]AuthType{ + "aad": AuthTypeAAD, + "acs": AuthTypeACS, + "accesscontrolservice": AuthTypeAccessControlService, + "azureactivedirectory": AuthTypeAzureActiveDirectory, + "invalid": AuthTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/id_certificate.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/id_certificate.go new file mode 100644 index 00000000000..b58f2c8ebc7 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/id_certificate.go @@ -0,0 +1,139 @@ +package vaultcertificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, vaultName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(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 := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) 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", "vaultName"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) 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("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/id_certificate_test.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/id_certificate_test.go new file mode 100644 index 00000000000..9fcdfd214c1 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/id_certificate_test.go @@ -0,0 +1,327 @@ +package vaultcertificates + +import ( + "testing" + + "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 = &CertificateId{} + +func TestNewCertificateID(t *testing.T) { + id := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "certificateName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.CertificateName != "certificateName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateName") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "certificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/certificates/certificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/certificates/certificateName", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/certificates/certificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/certificates/certificateName", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/certificates/certificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/cErTiFiCaTeS/cErTiFiCaTeNaMe", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + CertificateName: "cErTiFiCaTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/cErTiFiCaTeS/cErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateId(t *testing.T) { + segments := CertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/method_create.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/method_create.go new file mode 100644 index 00000000000..bb80ca8652b --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/method_create.go @@ -0,0 +1,57 @@ +package vaultcertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultCertificateResponse +} + +// Create ... +func (c VaultCertificatesClient) Create(ctx context.Context, id CertificateId, input CertificateRequest) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultCertificateResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_certificaterequest.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_certificaterequest.go new file mode 100644 index 00000000000..64984a9fb6e --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_certificaterequest.go @@ -0,0 +1,8 @@ +package vaultcertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateRequest struct { + Properties *RawCertificateData `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_rawcertificatedata.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_rawcertificatedata.go new file mode 100644 index 00000000000..2b6657d3813 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_rawcertificatedata.go @@ -0,0 +1,9 @@ +package vaultcertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RawCertificateData struct { + AuthType *AuthType `json:"authType,omitempty"` + Certificate *string `json:"certificate,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificateandaaddetails.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificateandaaddetails.go new file mode 100644 index 00000000000..89867a51ee0 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificateandaaddetails.go @@ -0,0 +1,99 @@ +package vaultcertificates + +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 _ ResourceCertificateDetails = ResourceCertificateAndAadDetails{} + +type ResourceCertificateAndAadDetails struct { + AadAudience *string `json:"aadAudience,omitempty"` + AadAuthority string `json:"aadAuthority"` + AadTenantId string `json:"aadTenantId"` + AzureManagementEndpointAudience string `json:"azureManagementEndpointAudience"` + ServicePrincipalClientId string `json:"servicePrincipalClientId"` + ServicePrincipalObjectId string `json:"servicePrincipalObjectId"` + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + + // Fields inherited from ResourceCertificateDetails + + AuthType string `json:"authType"` + Certificate *string `json:"certificate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Issuer *string `json:"issuer,omitempty"` + ResourceId *int64 `json:"resourceId,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ValidFrom *string `json:"validFrom,omitempty"` + ValidTo *string `json:"validTo,omitempty"` +} + +func (s ResourceCertificateAndAadDetails) ResourceCertificateDetails() BaseResourceCertificateDetailsImpl { + return BaseResourceCertificateDetailsImpl{ + AuthType: s.AuthType, + Certificate: s.Certificate, + FriendlyName: s.FriendlyName, + Issuer: s.Issuer, + ResourceId: s.ResourceId, + Subject: s.Subject, + Thumbprint: s.Thumbprint, + ValidFrom: s.ValidFrom, + ValidTo: s.ValidTo, + } +} + +func (o *ResourceCertificateAndAadDetails) GetValidFromAsTime() (*time.Time, error) { + if o.ValidFrom == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidFrom, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResourceCertificateAndAadDetails) SetValidFromAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidFrom = &formatted +} + +func (o *ResourceCertificateAndAadDetails) GetValidToAsTime() (*time.Time, error) { + if o.ValidTo == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidTo, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResourceCertificateAndAadDetails) SetValidToAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidTo = &formatted +} + +var _ json.Marshaler = ResourceCertificateAndAadDetails{} + +func (s ResourceCertificateAndAadDetails) MarshalJSON() ([]byte, error) { + type wrapper ResourceCertificateAndAadDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ResourceCertificateAndAadDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ResourceCertificateAndAadDetails: %+v", err) + } + + decoded["authType"] = "AzureActiveDirectory" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ResourceCertificateAndAadDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificateandacsdetails.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificateandacsdetails.go new file mode 100644 index 00000000000..f597e1c3d9b --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificateandacsdetails.go @@ -0,0 +1,95 @@ +package vaultcertificates + +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 _ ResourceCertificateDetails = ResourceCertificateAndAcsDetails{} + +type ResourceCertificateAndAcsDetails struct { + GlobalAcsHostName string `json:"globalAcsHostName"` + GlobalAcsNamespace string `json:"globalAcsNamespace"` + GlobalAcsRPRealm string `json:"globalAcsRPRealm"` + + // Fields inherited from ResourceCertificateDetails + + AuthType string `json:"authType"` + Certificate *string `json:"certificate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Issuer *string `json:"issuer,omitempty"` + ResourceId *int64 `json:"resourceId,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ValidFrom *string `json:"validFrom,omitempty"` + ValidTo *string `json:"validTo,omitempty"` +} + +func (s ResourceCertificateAndAcsDetails) ResourceCertificateDetails() BaseResourceCertificateDetailsImpl { + return BaseResourceCertificateDetailsImpl{ + AuthType: s.AuthType, + Certificate: s.Certificate, + FriendlyName: s.FriendlyName, + Issuer: s.Issuer, + ResourceId: s.ResourceId, + Subject: s.Subject, + Thumbprint: s.Thumbprint, + ValidFrom: s.ValidFrom, + ValidTo: s.ValidTo, + } +} + +func (o *ResourceCertificateAndAcsDetails) GetValidFromAsTime() (*time.Time, error) { + if o.ValidFrom == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidFrom, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResourceCertificateAndAcsDetails) SetValidFromAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidFrom = &formatted +} + +func (o *ResourceCertificateAndAcsDetails) GetValidToAsTime() (*time.Time, error) { + if o.ValidTo == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidTo, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResourceCertificateAndAcsDetails) SetValidToAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidTo = &formatted +} + +var _ json.Marshaler = ResourceCertificateAndAcsDetails{} + +func (s ResourceCertificateAndAcsDetails) MarshalJSON() ([]byte, error) { + type wrapper ResourceCertificateAndAcsDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ResourceCertificateAndAcsDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ResourceCertificateAndAcsDetails: %+v", err) + } + + decoded["authType"] = "AccessControlService" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ResourceCertificateAndAcsDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificatedetails.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificatedetails.go new file mode 100644 index 00000000000..bf10595b947 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_resourcecertificatedetails.go @@ -0,0 +1,91 @@ +package vaultcertificates + +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 ResourceCertificateDetails interface { + ResourceCertificateDetails() BaseResourceCertificateDetailsImpl +} + +var _ ResourceCertificateDetails = BaseResourceCertificateDetailsImpl{} + +type BaseResourceCertificateDetailsImpl struct { + AuthType string `json:"authType"` + Certificate *string `json:"certificate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Issuer *string `json:"issuer,omitempty"` + ResourceId *int64 `json:"resourceId,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ValidFrom *string `json:"validFrom,omitempty"` + ValidTo *string `json:"validTo,omitempty"` +} + +func (s BaseResourceCertificateDetailsImpl) ResourceCertificateDetails() BaseResourceCertificateDetailsImpl { + return s +} + +var _ ResourceCertificateDetails = RawResourceCertificateDetailsImpl{} + +// RawResourceCertificateDetailsImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawResourceCertificateDetailsImpl struct { + resourceCertificateDetails BaseResourceCertificateDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawResourceCertificateDetailsImpl) ResourceCertificateDetails() BaseResourceCertificateDetailsImpl { + return s.resourceCertificateDetails +} + +func UnmarshalResourceCertificateDetailsImplementation(input []byte) (ResourceCertificateDetails, 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 ResourceCertificateDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["authType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureActiveDirectory") { + var out ResourceCertificateAndAadDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ResourceCertificateAndAadDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AccessControlService") { + var out ResourceCertificateAndAcsDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ResourceCertificateAndAcsDetails: %+v", err) + } + return out, nil + } + + var parent BaseResourceCertificateDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseResourceCertificateDetailsImpl: %+v", err) + } + + return RawResourceCertificateDetailsImpl{ + resourceCertificateDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_vaultcertificateresponse.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_vaultcertificateresponse.go new file mode 100644 index 00000000000..6e7ee285c62 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/model_vaultcertificateresponse.go @@ -0,0 +1,48 @@ +package vaultcertificates + +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 VaultCertificateResponse struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ResourceCertificateDetails `json:"properties"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &VaultCertificateResponse{} + +func (s *VaultCertificateResponse) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling VaultCertificateResponse into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalResourceCertificateDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'VaultCertificateResponse': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultcertificates/version.go b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/version.go new file mode 100644 index 00000000000..f1db8d7f44b --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultcertificates/version.go @@ -0,0 +1,10 @@ +package vaultcertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vaultcertificates/2024-10-01" +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/README.md b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/README.md new file mode 100644 index 00000000000..d175fc2bbf5 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/README.md @@ -0,0 +1,78 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo` Documentation + +The `vaultextendedinfo` SDK allows for interaction with Azure Resource Manager `recoveryservices` (API Version `2024-10-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/recoveryservices/2024-10-01/vaultextendedinfo" +``` + + +### Client Initialization + +```go +client := vaultextendedinfo.NewVaultExtendedInfoClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VaultExtendedInfoClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := vaultextendedinfo.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := vaultextendedinfo.VaultExtendedInfoResource{ + // ... +} + + +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: `VaultExtendedInfoClient.Get` + +```go +ctx := context.TODO() +id := vaultextendedinfo.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +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: `VaultExtendedInfoClient.Update` + +```go +ctx := context.TODO() +id := vaultextendedinfo.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := vaultextendedinfo.VaultExtendedInfoResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/client.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/client.go new file mode 100644 index 00000000000..83e7308b418 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/client.go @@ -0,0 +1,26 @@ +package vaultextendedinfo + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultExtendedInfoClient struct { + Client *resourcemanager.Client +} + +func NewVaultExtendedInfoClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultExtendedInfoClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vaultextendedinfo", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultExtendedInfoClient: %+v", err) + } + + return &VaultExtendedInfoClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/id_vault.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/id_vault.go new file mode 100644 index 00000000000..6bcff1ccb31 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/id_vault.go @@ -0,0 +1,130 @@ +package vaultextendedinfo + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/id_vault_test.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/id_vault_test.go new file mode 100644 index 00000000000..dde69258bb1 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/id_vault_test.go @@ -0,0 +1,282 @@ +package vaultextendedinfo + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_createorupdate.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_createorupdate.go new file mode 100644 index 00000000000..2f7a0df28bc --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_createorupdate.go @@ -0,0 +1,58 @@ +package vaultextendedinfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *VaultExtendedInfoResource +} + +// CreateOrUpdate ... +func (c VaultExtendedInfoClient) CreateOrUpdate(ctx context.Context, id VaultId, input VaultExtendedInfoResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extendedInformation/vaultExtendedInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultExtendedInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_get.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_get.go new file mode 100644 index 00000000000..194e82e0c37 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_get.go @@ -0,0 +1,54 @@ +package vaultextendedinfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *VaultExtendedInfoResource +} + +// Get ... +func (c VaultExtendedInfoClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extendedInformation/vaultExtendedInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultExtendedInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_update.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_update.go new file mode 100644 index 00000000000..8b07cd20762 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/method_update.go @@ -0,0 +1,58 @@ +package vaultextendedinfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultExtendedInfoResource +} + +// Update ... +func (c VaultExtendedInfoClient) Update(ctx context.Context, id VaultId, input VaultExtendedInfoResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/extendedInformation/vaultExtendedInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultExtendedInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/model_vaultextendedinfo.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/model_vaultextendedinfo.go new file mode 100644 index 00000000000..a1514fbe948 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/model_vaultextendedinfo.go @@ -0,0 +1,11 @@ +package vaultextendedinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultExtendedInfo struct { + Algorithm *string `json:"algorithm,omitempty"` + EncryptionKey *string `json:"encryptionKey,omitempty"` + EncryptionKeyThumbprint *string `json:"encryptionKeyThumbprint,omitempty"` + IntegrityKey *string `json:"integrityKey,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/model_vaultextendedinforesource.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/model_vaultextendedinforesource.go new file mode 100644 index 00000000000..ee148aba996 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/model_vaultextendedinforesource.go @@ -0,0 +1,12 @@ +package vaultextendedinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultExtendedInfoResource struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultExtendedInfo `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/version.go b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/version.go new file mode 100644 index 00000000000..4e863ed53b0 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultextendedinfo/version.go @@ -0,0 +1,10 @@ +package vaultextendedinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vaultextendedinfo/2024-10-01" +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/README.md b/resource-manager/recoveryservices/2024-10-01/vaults/README.md new file mode 100644 index 00000000000..15396b19afc --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaults` Documentation + +The `vaults` SDK allows for interaction with Azure Resource Manager `recoveryservices` (API Version `2024-10-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaults" +``` + + +### Client Initialization + +```go +client := vaults.NewVaultsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VaultsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := vaults.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := vaults.Vault{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, vaults.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VaultsClient.Delete` + +```go +ctx := context.TODO() +id := vaults.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VaultsClient.Get` + +```go +ctx := context.TODO() +id := vaults.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +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: `VaultsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VaultsClient.ListBySubscriptionId` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscriptionId(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionIdComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VaultsClient.Update` + +```go +ctx := context.TODO() +id := vaults.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := vaults.PatchVault{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload, vaults.DefaultUpdateOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/client.go b/resource-manager/recoveryservices/2024-10-01/vaults/client.go new file mode 100644 index 00000000000..37bd7a44670 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/client.go @@ -0,0 +1,26 @@ +package vaults + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultsClient struct { + Client *resourcemanager.Client +} + +func NewVaultsClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vaults", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultsClient: %+v", err) + } + + return &VaultsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/constants.go b/resource-manager/recoveryservices/2024-10-01/vaults/constants.go new file mode 100644 index 00000000000..f9cf9b3216b --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/constants.go @@ -0,0 +1,958 @@ +package vaults + +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 AlertsState string + +const ( + AlertsStateDisabled AlertsState = "Disabled" + AlertsStateEnabled AlertsState = "Enabled" +) + +func PossibleValuesForAlertsState() []string { + return []string{ + string(AlertsStateDisabled), + string(AlertsStateEnabled), + } +} + +func (s *AlertsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlertsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAlertsState(input string) (*AlertsState, error) { + vals := map[string]AlertsState{ + "disabled": AlertsStateDisabled, + "enabled": AlertsStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AlertsState(input) + return &out, nil +} + +type BCDRSecurityLevel string + +const ( + BCDRSecurityLevelExcellent BCDRSecurityLevel = "Excellent" + BCDRSecurityLevelFair BCDRSecurityLevel = "Fair" + BCDRSecurityLevelGood BCDRSecurityLevel = "Good" + BCDRSecurityLevelPoor BCDRSecurityLevel = "Poor" +) + +func PossibleValuesForBCDRSecurityLevel() []string { + return []string{ + string(BCDRSecurityLevelExcellent), + string(BCDRSecurityLevelFair), + string(BCDRSecurityLevelGood), + string(BCDRSecurityLevelPoor), + } +} + +func (s *BCDRSecurityLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBCDRSecurityLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBCDRSecurityLevel(input string) (*BCDRSecurityLevel, error) { + vals := map[string]BCDRSecurityLevel{ + "excellent": BCDRSecurityLevelExcellent, + "fair": BCDRSecurityLevelFair, + "good": BCDRSecurityLevelGood, + "poor": BCDRSecurityLevelPoor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BCDRSecurityLevel(input) + return &out, nil +} + +type BackupStorageVersion string + +const ( + BackupStorageVersionUnassigned BackupStorageVersion = "Unassigned" + BackupStorageVersionVOne BackupStorageVersion = "V1" + BackupStorageVersionVTwo BackupStorageVersion = "V2" +) + +func PossibleValuesForBackupStorageVersion() []string { + return []string{ + string(BackupStorageVersionUnassigned), + string(BackupStorageVersionVOne), + string(BackupStorageVersionVTwo), + } +} + +func (s *BackupStorageVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupStorageVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupStorageVersion(input string) (*BackupStorageVersion, error) { + vals := map[string]BackupStorageVersion{ + "unassigned": BackupStorageVersionUnassigned, + "v1": BackupStorageVersionVOne, + "v2": BackupStorageVersionVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupStorageVersion(input) + return &out, nil +} + +type CrossRegionRestore string + +const ( + CrossRegionRestoreDisabled CrossRegionRestore = "Disabled" + CrossRegionRestoreEnabled CrossRegionRestore = "Enabled" +) + +func PossibleValuesForCrossRegionRestore() []string { + return []string{ + string(CrossRegionRestoreDisabled), + string(CrossRegionRestoreEnabled), + } +} + +func (s *CrossRegionRestore) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCrossRegionRestore(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCrossRegionRestore(input string) (*CrossRegionRestore, error) { + vals := map[string]CrossRegionRestore{ + "disabled": CrossRegionRestoreDisabled, + "enabled": CrossRegionRestoreEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CrossRegionRestore(input) + return &out, nil +} + +type CrossSubscriptionRestoreState string + +const ( + CrossSubscriptionRestoreStateDisabled CrossSubscriptionRestoreState = "Disabled" + CrossSubscriptionRestoreStateEnabled CrossSubscriptionRestoreState = "Enabled" + CrossSubscriptionRestoreStatePermanentlyDisabled CrossSubscriptionRestoreState = "PermanentlyDisabled" +) + +func PossibleValuesForCrossSubscriptionRestoreState() []string { + return []string{ + string(CrossSubscriptionRestoreStateDisabled), + string(CrossSubscriptionRestoreStateEnabled), + string(CrossSubscriptionRestoreStatePermanentlyDisabled), + } +} + +func (s *CrossSubscriptionRestoreState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCrossSubscriptionRestoreState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCrossSubscriptionRestoreState(input string) (*CrossSubscriptionRestoreState, error) { + vals := map[string]CrossSubscriptionRestoreState{ + "disabled": CrossSubscriptionRestoreStateDisabled, + "enabled": CrossSubscriptionRestoreStateEnabled, + "permanentlydisabled": CrossSubscriptionRestoreStatePermanentlyDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CrossSubscriptionRestoreState(input) + return &out, nil +} + +type EnhancedSecurityState string + +const ( + EnhancedSecurityStateAlwaysON EnhancedSecurityState = "AlwaysON" + EnhancedSecurityStateDisabled EnhancedSecurityState = "Disabled" + EnhancedSecurityStateEnabled EnhancedSecurityState = "Enabled" + EnhancedSecurityStateInvalid EnhancedSecurityState = "Invalid" +) + +func PossibleValuesForEnhancedSecurityState() []string { + return []string{ + string(EnhancedSecurityStateAlwaysON), + string(EnhancedSecurityStateDisabled), + string(EnhancedSecurityStateEnabled), + string(EnhancedSecurityStateInvalid), + } +} + +func (s *EnhancedSecurityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnhancedSecurityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnhancedSecurityState(input string) (*EnhancedSecurityState, error) { + vals := map[string]EnhancedSecurityState{ + "alwayson": EnhancedSecurityStateAlwaysON, + "disabled": EnhancedSecurityStateDisabled, + "enabled": EnhancedSecurityStateEnabled, + "invalid": EnhancedSecurityStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnhancedSecurityState(input) + return &out, nil +} + +type ImmutabilityState string + +const ( + ImmutabilityStateDisabled ImmutabilityState = "Disabled" + ImmutabilityStateLocked ImmutabilityState = "Locked" + ImmutabilityStateUnlocked ImmutabilityState = "Unlocked" +) + +func PossibleValuesForImmutabilityState() []string { + return []string{ + string(ImmutabilityStateDisabled), + string(ImmutabilityStateLocked), + string(ImmutabilityStateUnlocked), + } +} + +func (s *ImmutabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseImmutabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseImmutabilityState(input string) (*ImmutabilityState, error) { + vals := map[string]ImmutabilityState{ + "disabled": ImmutabilityStateDisabled, + "locked": ImmutabilityStateLocked, + "unlocked": ImmutabilityStateUnlocked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ImmutabilityState(input) + return &out, nil +} + +type InfrastructureEncryptionState string + +const ( + InfrastructureEncryptionStateDisabled InfrastructureEncryptionState = "Disabled" + InfrastructureEncryptionStateEnabled InfrastructureEncryptionState = "Enabled" +) + +func PossibleValuesForInfrastructureEncryptionState() []string { + return []string{ + string(InfrastructureEncryptionStateDisabled), + string(InfrastructureEncryptionStateEnabled), + } +} + +func (s *InfrastructureEncryptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInfrastructureEncryptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInfrastructureEncryptionState(input string) (*InfrastructureEncryptionState, error) { + vals := map[string]InfrastructureEncryptionState{ + "disabled": InfrastructureEncryptionStateDisabled, + "enabled": InfrastructureEncryptionStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InfrastructureEncryptionState(input) + return &out, nil +} + +type MultiUserAuthorization string + +const ( + MultiUserAuthorizationDisabled MultiUserAuthorization = "Disabled" + MultiUserAuthorizationEnabled MultiUserAuthorization = "Enabled" + MultiUserAuthorizationInvalid MultiUserAuthorization = "Invalid" +) + +func PossibleValuesForMultiUserAuthorization() []string { + return []string{ + string(MultiUserAuthorizationDisabled), + string(MultiUserAuthorizationEnabled), + string(MultiUserAuthorizationInvalid), + } +} + +func (s *MultiUserAuthorization) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiUserAuthorization(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiUserAuthorization(input string) (*MultiUserAuthorization, error) { + vals := map[string]MultiUserAuthorization{ + "disabled": MultiUserAuthorizationDisabled, + "enabled": MultiUserAuthorizationEnabled, + "invalid": MultiUserAuthorizationInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiUserAuthorization(input) + return &out, nil +} + +type PrivateEndpointConnectionStatus string + +const ( + PrivateEndpointConnectionStatusApproved PrivateEndpointConnectionStatus = "Approved" + PrivateEndpointConnectionStatusDisconnected PrivateEndpointConnectionStatus = "Disconnected" + PrivateEndpointConnectionStatusPending PrivateEndpointConnectionStatus = "Pending" + PrivateEndpointConnectionStatusRejected PrivateEndpointConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointConnectionStatus() []string { + return []string{ + string(PrivateEndpointConnectionStatusApproved), + string(PrivateEndpointConnectionStatusDisconnected), + string(PrivateEndpointConnectionStatusPending), + string(PrivateEndpointConnectionStatusRejected), + } +} + +func (s *PrivateEndpointConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionStatus(input string) (*PrivateEndpointConnectionStatus, error) { + vals := map[string]PrivateEndpointConnectionStatus{ + "approved": PrivateEndpointConnectionStatusApproved, + "disconnected": PrivateEndpointConnectionStatusDisconnected, + "pending": PrivateEndpointConnectionStatusPending, + "rejected": PrivateEndpointConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStatePending ProvisioningState = "Pending" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStatePending), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "pending": ProvisioningStatePending, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type ResourceMoveState string + +const ( + ResourceMoveStateCommitFailed ResourceMoveState = "CommitFailed" + ResourceMoveStateCommitTimedout ResourceMoveState = "CommitTimedout" + ResourceMoveStateCriticalFailure ResourceMoveState = "CriticalFailure" + ResourceMoveStateFailure ResourceMoveState = "Failure" + ResourceMoveStateInProgress ResourceMoveState = "InProgress" + ResourceMoveStateMoveSucceeded ResourceMoveState = "MoveSucceeded" + ResourceMoveStatePartialSuccess ResourceMoveState = "PartialSuccess" + ResourceMoveStatePrepareFailed ResourceMoveState = "PrepareFailed" + ResourceMoveStatePrepareTimedout ResourceMoveState = "PrepareTimedout" + ResourceMoveStateUnknown ResourceMoveState = "Unknown" +) + +func PossibleValuesForResourceMoveState() []string { + return []string{ + string(ResourceMoveStateCommitFailed), + string(ResourceMoveStateCommitTimedout), + string(ResourceMoveStateCriticalFailure), + string(ResourceMoveStateFailure), + string(ResourceMoveStateInProgress), + string(ResourceMoveStateMoveSucceeded), + string(ResourceMoveStatePartialSuccess), + string(ResourceMoveStatePrepareFailed), + string(ResourceMoveStatePrepareTimedout), + string(ResourceMoveStateUnknown), + } +} + +func (s *ResourceMoveState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceMoveState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceMoveState(input string) (*ResourceMoveState, error) { + vals := map[string]ResourceMoveState{ + "commitfailed": ResourceMoveStateCommitFailed, + "committimedout": ResourceMoveStateCommitTimedout, + "criticalfailure": ResourceMoveStateCriticalFailure, + "failure": ResourceMoveStateFailure, + "inprogress": ResourceMoveStateInProgress, + "movesucceeded": ResourceMoveStateMoveSucceeded, + "partialsuccess": ResourceMoveStatePartialSuccess, + "preparefailed": ResourceMoveStatePrepareFailed, + "preparetimedout": ResourceMoveStatePrepareTimedout, + "unknown": ResourceMoveStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceMoveState(input) + return &out, nil +} + +type SecureScoreLevel string + +const ( + SecureScoreLevelAdequate SecureScoreLevel = "Adequate" + SecureScoreLevelMaximum SecureScoreLevel = "Maximum" + SecureScoreLevelMinimum SecureScoreLevel = "Minimum" + SecureScoreLevelNone SecureScoreLevel = "None" +) + +func PossibleValuesForSecureScoreLevel() []string { + return []string{ + string(SecureScoreLevelAdequate), + string(SecureScoreLevelMaximum), + string(SecureScoreLevelMinimum), + string(SecureScoreLevelNone), + } +} + +func (s *SecureScoreLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecureScoreLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecureScoreLevel(input string) (*SecureScoreLevel, error) { + vals := map[string]SecureScoreLevel{ + "adequate": SecureScoreLevelAdequate, + "maximum": SecureScoreLevelMaximum, + "minimum": SecureScoreLevelMinimum, + "none": SecureScoreLevelNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecureScoreLevel(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameRSZero SkuName = "RS0" + SkuNameStandard SkuName = "Standard" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameRSZero), + string(SkuNameStandard), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "rs0": SkuNameRSZero, + "standard": SkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type SoftDeleteState string + +const ( + SoftDeleteStateAlwaysON SoftDeleteState = "AlwaysON" + SoftDeleteStateDisabled SoftDeleteState = "Disabled" + SoftDeleteStateEnabled SoftDeleteState = "Enabled" + SoftDeleteStateInvalid SoftDeleteState = "Invalid" +) + +func PossibleValuesForSoftDeleteState() []string { + return []string{ + string(SoftDeleteStateAlwaysON), + string(SoftDeleteStateDisabled), + string(SoftDeleteStateEnabled), + string(SoftDeleteStateInvalid), + } +} + +func (s *SoftDeleteState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSoftDeleteState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSoftDeleteState(input string) (*SoftDeleteState, error) { + vals := map[string]SoftDeleteState{ + "alwayson": SoftDeleteStateAlwaysON, + "disabled": SoftDeleteStateDisabled, + "enabled": SoftDeleteStateEnabled, + "invalid": SoftDeleteStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SoftDeleteState(input) + return &out, nil +} + +type StandardTierStorageRedundancy string + +const ( + StandardTierStorageRedundancyGeoRedundant StandardTierStorageRedundancy = "GeoRedundant" + StandardTierStorageRedundancyInvalid StandardTierStorageRedundancy = "Invalid" + StandardTierStorageRedundancyLocallyRedundant StandardTierStorageRedundancy = "LocallyRedundant" + StandardTierStorageRedundancyZoneRedundant StandardTierStorageRedundancy = "ZoneRedundant" +) + +func PossibleValuesForStandardTierStorageRedundancy() []string { + return []string{ + string(StandardTierStorageRedundancyGeoRedundant), + string(StandardTierStorageRedundancyInvalid), + string(StandardTierStorageRedundancyLocallyRedundant), + string(StandardTierStorageRedundancyZoneRedundant), + } +} + +func (s *StandardTierStorageRedundancy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStandardTierStorageRedundancy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStandardTierStorageRedundancy(input string) (*StandardTierStorageRedundancy, error) { + vals := map[string]StandardTierStorageRedundancy{ + "georedundant": StandardTierStorageRedundancyGeoRedundant, + "invalid": StandardTierStorageRedundancyInvalid, + "locallyredundant": StandardTierStorageRedundancyLocallyRedundant, + "zoneredundant": StandardTierStorageRedundancyZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StandardTierStorageRedundancy(input) + return &out, nil +} + +type TriggerType string + +const ( + TriggerTypeForcedUpgrade TriggerType = "ForcedUpgrade" + TriggerTypeUserTriggered TriggerType = "UserTriggered" +) + +func PossibleValuesForTriggerType() []string { + return []string{ + string(TriggerTypeForcedUpgrade), + string(TriggerTypeUserTriggered), + } +} + +func (s *TriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerType(input string) (*TriggerType, error) { + vals := map[string]TriggerType{ + "forcedupgrade": TriggerTypeForcedUpgrade, + "usertriggered": TriggerTypeUserTriggered, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerType(input) + return &out, nil +} + +type VaultPrivateEndpointState string + +const ( + VaultPrivateEndpointStateEnabled VaultPrivateEndpointState = "Enabled" + VaultPrivateEndpointStateNone VaultPrivateEndpointState = "None" +) + +func PossibleValuesForVaultPrivateEndpointState() []string { + return []string{ + string(VaultPrivateEndpointStateEnabled), + string(VaultPrivateEndpointStateNone), + } +} + +func (s *VaultPrivateEndpointState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultPrivateEndpointState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVaultPrivateEndpointState(input string) (*VaultPrivateEndpointState, error) { + vals := map[string]VaultPrivateEndpointState{ + "enabled": VaultPrivateEndpointStateEnabled, + "none": VaultPrivateEndpointStateNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultPrivateEndpointState(input) + return &out, nil +} + +type VaultSubResourceType string + +const ( + VaultSubResourceTypeAzureBackup VaultSubResourceType = "AzureBackup" + VaultSubResourceTypeAzureBackupSecondary VaultSubResourceType = "AzureBackup_secondary" + VaultSubResourceTypeAzureSiteRecovery VaultSubResourceType = "AzureSiteRecovery" +) + +func PossibleValuesForVaultSubResourceType() []string { + return []string{ + string(VaultSubResourceTypeAzureBackup), + string(VaultSubResourceTypeAzureBackupSecondary), + string(VaultSubResourceTypeAzureSiteRecovery), + } +} + +func (s *VaultSubResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultSubResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVaultSubResourceType(input string) (*VaultSubResourceType, error) { + vals := map[string]VaultSubResourceType{ + "azurebackup": VaultSubResourceTypeAzureBackup, + "azurebackup_secondary": VaultSubResourceTypeAzureBackupSecondary, + "azuresiterecovery": VaultSubResourceTypeAzureSiteRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultSubResourceType(input) + return &out, nil +} + +type VaultUpgradeState string + +const ( + VaultUpgradeStateFailed VaultUpgradeState = "Failed" + VaultUpgradeStateInProgress VaultUpgradeState = "InProgress" + VaultUpgradeStateUnknown VaultUpgradeState = "Unknown" + VaultUpgradeStateUpgraded VaultUpgradeState = "Upgraded" +) + +func PossibleValuesForVaultUpgradeState() []string { + return []string{ + string(VaultUpgradeStateFailed), + string(VaultUpgradeStateInProgress), + string(VaultUpgradeStateUnknown), + string(VaultUpgradeStateUpgraded), + } +} + +func (s *VaultUpgradeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultUpgradeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVaultUpgradeState(input string) (*VaultUpgradeState, error) { + vals := map[string]VaultUpgradeState{ + "failed": VaultUpgradeStateFailed, + "inprogress": VaultUpgradeStateInProgress, + "unknown": VaultUpgradeStateUnknown, + "upgraded": VaultUpgradeStateUpgraded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultUpgradeState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/id_vault.go b/resource-manager/recoveryservices/2024-10-01/vaults/id_vault.go new file mode 100644 index 00000000000..9c23a25bcb7 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/id_vault.go @@ -0,0 +1,130 @@ +package vaults + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservices/2024-10-01/vaults/id_vault_test.go b/resource-manager/recoveryservices/2024-10-01/vaults/id_vault_test.go new file mode 100644 index 00000000000..0641240427b --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/id_vault_test.go @@ -0,0 +1,282 @@ +package vaults + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/method_createorupdate.go b/resource-manager/recoveryservices/2024-10-01/vaults/method_createorupdate.go new file mode 100644 index 00000000000..f52787d1b5a --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/method_createorupdate.go @@ -0,0 +1,104 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Vault +} + +type CreateOrUpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c VaultsClient) CreateOrUpdate(ctx context.Context, id VaultId, input Vault, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VaultsClient) CreateOrUpdateThenPoll(ctx context.Context, id VaultId, input Vault, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/method_delete.go b/resource-manager/recoveryservices/2024-10-01/vaults/method_delete.go new file mode 100644 index 00000000000..2b8f5be41af --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/method_delete.go @@ -0,0 +1,70 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VaultsClient) Delete(ctx context.Context, id VaultId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VaultsClient) DeleteThenPoll(ctx context.Context, id VaultId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/method_get.go b/resource-manager/recoveryservices/2024-10-01/vaults/method_get.go new file mode 100644 index 00000000000..64a64f258ff --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/method_get.go @@ -0,0 +1,53 @@ +package vaults + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *Vault +} + +// Get ... +func (c VaultsClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Vault + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/method_listbyresourcegroup.go b/resource-manager/recoveryservices/2024-10-01/vaults/method_listbyresourcegroup.go new file mode 100644 index 00000000000..61ef1d6955e --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Vault +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Vault +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c VaultsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/vaults", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Vault `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c VaultsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, VaultOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VaultsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VaultOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Vault, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/method_listbysubscriptionid.go b/resource-manager/recoveryservices/2024-10-01/vaults/method_listbysubscriptionid.go new file mode 100644 index 00000000000..c289dedd82f --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/method_listbysubscriptionid.go @@ -0,0 +1,106 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Vault +} + +type ListBySubscriptionIdCompleteResult struct { + LatestHttpResponse *http.Response + Items []Vault +} + +type ListBySubscriptionIdCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionIdCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscriptionId ... +func (c VaultsClient) ListBySubscriptionId(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionIdCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/vaults", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Vault `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionIdComplete retrieves all the results into a single object +func (c VaultsClient) ListBySubscriptionIdComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionIdCompleteResult, error) { + return c.ListBySubscriptionIdCompleteMatchingPredicate(ctx, id, VaultOperationPredicate{}) +} + +// ListBySubscriptionIdCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VaultsClient) ListBySubscriptionIdCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VaultOperationPredicate) (result ListBySubscriptionIdCompleteResult, err error) { + items := make([]Vault, 0) + + resp, err := c.ListBySubscriptionId(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionIdCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/method_update.go b/resource-manager/recoveryservices/2024-10-01/vaults/method_update.go new file mode 100644 index 00000000000..fed13b914bf --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/method_update.go @@ -0,0 +1,104 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Vault +} + +type UpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c VaultsClient) Update(ctx context.Context, id VaultId, input PatchVault, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c VaultsClient) UpdateThenPoll(ctx context.Context, id VaultId, input PatchVault, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_azuremonitoralertsettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_azuremonitoralertsettings.go new file mode 100644 index 00000000000..3f36e0be907 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_azuremonitoralertsettings.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureMonitorAlertSettings struct { + AlertsForAllFailoverIssues *AlertsState `json:"alertsForAllFailoverIssues,omitempty"` + AlertsForAllJobFailures *AlertsState `json:"alertsForAllJobFailures,omitempty"` + AlertsForAllReplicationIssues *AlertsState `json:"alertsForAllReplicationIssues,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_classicalertsettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_classicalertsettings.go new file mode 100644 index 00000000000..bf08cd1a80e --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_classicalertsettings.go @@ -0,0 +1,9 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClassicAlertSettings struct { + AlertsForCriticalOperations *AlertsState `json:"alertsForCriticalOperations,omitempty"` + EmailNotificationsForSiteRecovery *AlertsState `json:"emailNotificationsForSiteRecovery,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_cmkkekidentity.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_cmkkekidentity.go new file mode 100644 index 00000000000..1e5e7be3d2d --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_cmkkekidentity.go @@ -0,0 +1,9 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CmkKekIdentity struct { + UseSystemAssignedIdentity *bool `json:"useSystemAssignedIdentity,omitempty"` + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_cmkkeyvaultproperties.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_cmkkeyvaultproperties.go new file mode 100644 index 00000000000..c53f530b9f5 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_cmkkeyvaultproperties.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CmkKeyVaultProperties struct { + KeyUri *string `json:"keyUri,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_crosssubscriptionrestoresettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_crosssubscriptionrestoresettings.go new file mode 100644 index 00000000000..4a4fecb8bdd --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_crosssubscriptionrestoresettings.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CrossSubscriptionRestoreSettings struct { + CrossSubscriptionRestoreState *CrossSubscriptionRestoreState `json:"crossSubscriptionRestoreState,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_immutabilitysettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_immutabilitysettings.go new file mode 100644 index 00000000000..f52ae97a4c3 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_immutabilitysettings.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImmutabilitySettings struct { + State *ImmutabilityState `json:"state,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_monitoringsettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_monitoringsettings.go new file mode 100644 index 00000000000..391ede46ae2 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_monitoringsettings.go @@ -0,0 +1,9 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoringSettings struct { + AzureMonitorAlertSettings *AzureMonitorAlertSettings `json:"azureMonitorAlertSettings,omitempty"` + ClassicAlertSettings *ClassicAlertSettings `json:"classicAlertSettings,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_patchvault.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_patchvault.go new file mode 100644 index 00000000000..5ffc9615bc5 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_patchvault.go @@ -0,0 +1,20 @@ +package vaults + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchVault struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpoint.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpoint.go new file mode 100644 index 00000000000..64ce35a3d98 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpoint.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpointconnection.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpointconnection.go new file mode 100644 index 00000000000..687aefc111c --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + GroupIds *[]VaultSubResourceType `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpointconnectionvaultproperties.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpointconnectionvaultproperties.go new file mode 100644 index 00000000000..5758db1bfa3 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_privateendpointconnectionvaultproperties.go @@ -0,0 +1,12 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionVaultProperties struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnection `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_privatelinkserviceconnectionstate.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..b07724e0e27 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_restoresettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_restoresettings.go new file mode 100644 index 00000000000..b5126dbe263 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_restoresettings.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreSettings struct { + CrossSubscriptionRestoreSettings *CrossSubscriptionRestoreSettings `json:"crossSubscriptionRestoreSettings,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_securitysettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_securitysettings.go new file mode 100644 index 00000000000..b5c9821e944 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_securitysettings.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuritySettings struct { + ImmutabilitySettings *ImmutabilitySettings `json:"immutabilitySettings,omitempty"` + MultiUserAuthorization *MultiUserAuthorization `json:"multiUserAuthorization,omitempty"` + SoftDeleteSettings *SoftDeleteSettings `json:"softDeleteSettings,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_sku.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_sku.go new file mode 100644 index 00000000000..d89e1340ee6 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_sku.go @@ -0,0 +1,12 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *string `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name SkuName `json:"name"` + Size *string `json:"size,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_softdeletesettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_softdeletesettings.go new file mode 100644 index 00000000000..fb257ac28c7 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_softdeletesettings.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SoftDeleteSettings struct { + EnhancedSecurityState *EnhancedSecurityState `json:"enhancedSecurityState,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SoftDeleteState *SoftDeleteState `json:"softDeleteState,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_upgradedetails.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_upgradedetails.go new file mode 100644 index 00000000000..f5e021983ab --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_upgradedetails.go @@ -0,0 +1,58 @@ +package vaults + +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 UpgradeDetails struct { + EndTimeUtc *string `json:"endTimeUtc,omitempty"` + LastUpdatedTimeUtc *string `json:"lastUpdatedTimeUtc,omitempty"` + Message *string `json:"message,omitempty"` + OperationId *string `json:"operationId,omitempty"` + PreviousResourceId *string `json:"previousResourceId,omitempty"` + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + Status *VaultUpgradeState `json:"status,omitempty"` + TriggerType *TriggerType `json:"triggerType,omitempty"` + UpgradedResourceId *string `json:"upgradedResourceId,omitempty"` +} + +func (o *UpgradeDetails) GetEndTimeUtcAsTime() (*time.Time, error) { + if o.EndTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpgradeDetails) SetEndTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTimeUtc = &formatted +} + +func (o *UpgradeDetails) GetLastUpdatedTimeUtcAsTime() (*time.Time, error) { + if o.LastUpdatedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpgradeDetails) SetLastUpdatedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedTimeUtc = &formatted +} + +func (o *UpgradeDetails) GetStartTimeUtcAsTime() (*time.Time, error) { + if o.StartTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpgradeDetails) SetStartTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_vault.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_vault.go new file mode 100644 index 00000000000..dc5d7d049c1 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_vault.go @@ -0,0 +1,22 @@ +package vaults + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Vault struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *VaultProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultproperties.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultproperties.go new file mode 100644 index 00000000000..5942dc4f409 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultproperties.go @@ -0,0 +1,24 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultProperties struct { + BackupStorageVersion *BackupStorageVersion `json:"backupStorageVersion,omitempty"` + BcdrSecurityLevel *BCDRSecurityLevel `json:"bcdrSecurityLevel,omitempty"` + Encryption *VaultPropertiesEncryption `json:"encryption,omitempty"` + MonitoringSettings *MonitoringSettings `json:"monitoringSettings,omitempty"` + MoveDetails *VaultPropertiesMoveDetails `json:"moveDetails,omitempty"` + MoveState *ResourceMoveState `json:"moveState,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnectionVaultProperties `json:"privateEndpointConnections,omitempty"` + PrivateEndpointStateForBackup *VaultPrivateEndpointState `json:"privateEndpointStateForBackup,omitempty"` + PrivateEndpointStateForSiteRecovery *VaultPrivateEndpointState `json:"privateEndpointStateForSiteRecovery,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + RedundancySettings *VaultPropertiesRedundancySettings `json:"redundancySettings,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + RestoreSettings *RestoreSettings `json:"restoreSettings,omitempty"` + SecureScore *SecureScoreLevel `json:"secureScore,omitempty"` + SecuritySettings *SecuritySettings `json:"securitySettings,omitempty"` + UpgradeDetails *UpgradeDetails `json:"upgradeDetails,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesencryption.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesencryption.go new file mode 100644 index 00000000000..05c6effec1d --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesencryption.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultPropertiesEncryption struct { + InfrastructureEncryption *InfrastructureEncryptionState `json:"infrastructureEncryption,omitempty"` + KekIdentity *CmkKekIdentity `json:"kekIdentity,omitempty"` + KeyVaultProperties *CmkKeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesmovedetails.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesmovedetails.go new file mode 100644 index 00000000000..b65be5a0669 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesmovedetails.go @@ -0,0 +1,42 @@ +package vaults + +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 VaultPropertiesMoveDetails struct { + CompletionTimeUtc *string `json:"completionTimeUtc,omitempty"` + OperationId *string `json:"operationId,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` +} + +func (o *VaultPropertiesMoveDetails) GetCompletionTimeUtcAsTime() (*time.Time, error) { + if o.CompletionTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CompletionTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultPropertiesMoveDetails) SetCompletionTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CompletionTimeUtc = &formatted +} + +func (o *VaultPropertiesMoveDetails) GetStartTimeUtcAsTime() (*time.Time, error) { + if o.StartTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultPropertiesMoveDetails) SetStartTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesredundancysettings.go b/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesredundancysettings.go new file mode 100644 index 00000000000..2d1174f221f --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/model_vaultpropertiesredundancysettings.go @@ -0,0 +1,9 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultPropertiesRedundancySettings struct { + CrossRegionRestore *CrossRegionRestore `json:"crossRegionRestore,omitempty"` + StandardTierStorageRedundancy *StandardTierStorageRedundancy `json:"standardTierStorageRedundancy,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaults/predicates.go b/resource-manager/recoveryservices/2024-10-01/vaults/predicates.go new file mode 100644 index 00000000000..1039a9afe4e --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/predicates.go @@ -0,0 +1,37 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VaultOperationPredicate) Matches(input Vault) 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 && *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/resource-manager/recoveryservices/2024-10-01/vaults/version.go b/resource-manager/recoveryservices/2024-10-01/vaults/version.go new file mode 100644 index 00000000000..9d808686adc --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaults/version.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vaults/2024-10-01" +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/README.md b/resource-manager/recoveryservices/2024-10-01/vaultusages/README.md new file mode 100644 index 00000000000..92c3013f4f7 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-10-01/vaultusages` Documentation + +The `vaultusages` SDK allows for interaction with Azure Resource Manager `recoveryservices` (API Version `2024-10-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/recoveryservices/2024-10-01/vaultusages" +``` + + +### Client Initialization + +```go +client := vaultusages.NewVaultUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VaultUsagesClient.UsagesListByVaults` + +```go +ctx := context.TODO() +id := vaultusages.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +read, err := client.UsagesListByVaults(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/client.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/client.go new file mode 100644 index 00000000000..c3899c6950a --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/client.go @@ -0,0 +1,26 @@ +package vaultusages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultUsagesClient struct { + Client *resourcemanager.Client +} + +func NewVaultUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultUsagesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vaultusages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultUsagesClient: %+v", err) + } + + return &VaultUsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/constants.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/constants.go new file mode 100644 index 00000000000..333eba1e6c6 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/constants.go @@ -0,0 +1,63 @@ +package vaultusages + +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 UsagesUnit string + +const ( + UsagesUnitBytes UsagesUnit = "Bytes" + UsagesUnitBytesPerSecond UsagesUnit = "BytesPerSecond" + UsagesUnitCount UsagesUnit = "Count" + UsagesUnitCountPerSecond UsagesUnit = "CountPerSecond" + UsagesUnitPercent UsagesUnit = "Percent" + UsagesUnitSeconds UsagesUnit = "Seconds" +) + +func PossibleValuesForUsagesUnit() []string { + return []string{ + string(UsagesUnitBytes), + string(UsagesUnitBytesPerSecond), + string(UsagesUnitCount), + string(UsagesUnitCountPerSecond), + string(UsagesUnitPercent), + string(UsagesUnitSeconds), + } +} + +func (s *UsagesUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsagesUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsagesUnit(input string) (*UsagesUnit, error) { + vals := map[string]UsagesUnit{ + "bytes": UsagesUnitBytes, + "bytespersecond": UsagesUnitBytesPerSecond, + "count": UsagesUnitCount, + "countpersecond": UsagesUnitCountPerSecond, + "percent": UsagesUnitPercent, + "seconds": UsagesUnitSeconds, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsagesUnit(input) + return &out, nil +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/id_vault.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/id_vault.go new file mode 100644 index 00000000000..9135a13603a --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/id_vault.go @@ -0,0 +1,130 @@ +package vaultusages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservices/2024-10-01/vaultusages/id_vault_test.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/id_vault_test.go new file mode 100644 index 00000000000..7a214c51b29 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/id_vault_test.go @@ -0,0 +1,282 @@ +package vaultusages + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/method_usageslistbyvaults.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/method_usageslistbyvaults.go new file mode 100644 index 00000000000..283b1da78f2 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/method_usageslistbyvaults.go @@ -0,0 +1,54 @@ +package vaultusages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsagesListByVaultsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultUsageList +} + +// UsagesListByVaults ... +func (c VaultUsagesClient) UsagesListByVaults(ctx context.Context, id VaultId) (result UsagesListByVaultsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultUsageList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/model_nameinfo.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/model_nameinfo.go new file mode 100644 index 00000000000..974668c26f9 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/model_nameinfo.go @@ -0,0 +1,9 @@ +package vaultusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameInfo struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/model_vaultusage.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/model_vaultusage.go new file mode 100644 index 00000000000..6b7bc2b68d8 --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/model_vaultusage.go @@ -0,0 +1,31 @@ +package vaultusages + +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 VaultUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *NameInfo `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + Unit *UsagesUnit `json:"unit,omitempty"` +} + +func (o *VaultUsage) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultUsage) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/model_vaultusagelist.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/model_vaultusagelist.go new file mode 100644 index 00000000000..aa529e6fcbf --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/model_vaultusagelist.go @@ -0,0 +1,8 @@ +package vaultusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultUsageList struct { + Value *[]VaultUsage `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-10-01/vaultusages/version.go b/resource-manager/recoveryservices/2024-10-01/vaultusages/version.go new file mode 100644 index 00000000000..541fd148f8a --- /dev/null +++ b/resource-manager/recoveryservices/2024-10-01/vaultusages/version.go @@ -0,0 +1,10 @@ +package vaultusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vaultusages/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/README.md new file mode 100644 index 00000000000..48293059600 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupengines` Documentation + +The `backupengines` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupengines" +``` + + +### Client Initialization + +```go +client := backupengines.NewBackupEnginesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupEnginesClient.Get` + +```go +ctx := context.TODO() +id := backupengines.NewBackupEngineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupEngineName") + +read, err := client.Get(ctx, id, backupengines.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupEnginesClient.List` + +```go +ctx := context.TODO() +id := backupengines.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, backupengines.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupengines.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/client.go new file mode 100644 index 00000000000..3f415af9d81 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/client.go @@ -0,0 +1,18 @@ +package backupengines + +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 BackupEnginesClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupEnginesClientWithBaseURI(endpoint string) BackupEnginesClient { + return BackupEnginesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/constants.go new file mode 100644 index 00000000000..0fea886304e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/constants.go @@ -0,0 +1,88 @@ +package backupengines + +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 BackupEngineType string + +const ( + BackupEngineTypeAzureBackupServerEngine BackupEngineType = "AzureBackupServerEngine" + BackupEngineTypeDpmBackupEngine BackupEngineType = "DpmBackupEngine" + BackupEngineTypeInvalid BackupEngineType = "Invalid" +) + +func PossibleValuesForBackupEngineType() []string { + return []string{ + string(BackupEngineTypeAzureBackupServerEngine), + string(BackupEngineTypeDpmBackupEngine), + string(BackupEngineTypeInvalid), + } +} + +func parseBackupEngineType(input string) (*BackupEngineType, error) { + vals := map[string]BackupEngineType{ + "azurebackupserverengine": BackupEngineTypeAzureBackupServerEngine, + "dpmbackupengine": BackupEngineTypeDpmBackupEngine, + "invalid": BackupEngineTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupEngineType(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 +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_backupengine.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_backupengine.go new file mode 100644 index 00000000000..a77c43c3207 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_backupengine.go @@ -0,0 +1,139 @@ +package backupengines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupEngineId{}) +} + +var _ resourceids.ResourceId = &BackupEngineId{} + +// BackupEngineId is a struct representing the Resource ID for a Backup Engine +type BackupEngineId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupEngineName string +} + +// NewBackupEngineID returns a new BackupEngineId struct +func NewBackupEngineID(subscriptionId string, resourceGroupName string, vaultName string, backupEngineName string) BackupEngineId { + return BackupEngineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupEngineName: backupEngineName, + } +} + +// ParseBackupEngineID parses 'input' into a BackupEngineId +func ParseBackupEngineID(input string) (*BackupEngineId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupEngineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupEngineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupEngineIDInsensitively parses 'input' case-insensitively into a BackupEngineId +// note: this method should only be used for API response data and not user input +func ParseBackupEngineIDInsensitively(input string) (*BackupEngineId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupEngineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupEngineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupEngineId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupEngineName, ok = input.Parsed["backupEngineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupEngineName", input) + } + + return nil +} + +// ValidateBackupEngineID checks that 'input' can be parsed as a Backup Engine ID +func ValidateBackupEngineID(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 := ParseBackupEngineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Engine ID +func (id BackupEngineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupEngines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupEngineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Engine ID +func (id BackupEngineId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupEngines", "backupEngines", "backupEngines"), + resourceids.UserSpecifiedSegment("backupEngineName", "backupEngineName"), + } +} + +// String returns a human-readable description of this Backup Engine ID +func (id BackupEngineId) 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 Engine Name: %q", id.BackupEngineName), + } + return fmt.Sprintf("Backup Engine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_backupengine_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_backupengine_test.go new file mode 100644 index 00000000000..3f5fff13d31 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_backupengine_test.go @@ -0,0 +1,327 @@ +package backupengines + +import ( + "testing" + + "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 = &BackupEngineId{} + +func TestNewBackupEngineID(t *testing.T) { + id := NewBackupEngineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupEngineName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupEngineName != "backupEngineName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupEngineName'", id.BackupEngineName, "backupEngineName") + } +} + +func TestFormatBackupEngineID(t *testing.T) { + actual := NewBackupEngineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupEngineName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupEngines/backupEngineName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupEngineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupEngineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupEngines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupEngines/backupEngineName", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupEngineName: "backupEngineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupEngines/backupEngineName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupEngineID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupEngineName != v.Expected.BackupEngineName { + t.Fatalf("Expected %q but got %q for BackupEngineName", v.Expected.BackupEngineName, actual.BackupEngineName) + } + + } +} + +func TestParseBackupEngineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupEngineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupEngines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPeNgInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupEngines/backupEngineName", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupEngineName: "backupEngineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupEngines/backupEngineName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPeNgInEs/bAcKuPeNgInEnAmE", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupEngineName: "bAcKuPeNgInEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPeNgInEs/bAcKuPeNgInEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupEngineIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupEngineName != v.Expected.BackupEngineName { + t.Fatalf("Expected %q but got %q for BackupEngineName", v.Expected.BackupEngineName, actual.BackupEngineName) + } + + } +} + +func TestSegmentsForBackupEngineId(t *testing.T) { + segments := BackupEngineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupEngineId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_vault.go new file mode 100644 index 00000000000..7d0a988db40 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_vault.go @@ -0,0 +1,130 @@ +package backupengines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_vault_test.go new file mode 100644 index 00000000000..264a070a296 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/id_vault_test.go @@ -0,0 +1,282 @@ +package backupengines + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/method_get_autorest.go new file mode 100644 index 00000000000..e4493845ef2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/method_get_autorest.go @@ -0,0 +1,97 @@ +package backupengines + +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 *BackupEngineBaseResource +} + +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 BackupEnginesClient) Get(ctx context.Context, id BackupEngineId, options GetOperationOptions) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupEnginesClient) preparerForGet(ctx context.Context, id BackupEngineId, 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 BackupEnginesClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/method_list_autorest.go new file mode 100644 index 00000000000..bfc2eb661b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupengines + +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 *[]BackupEngineBaseResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []BackupEngineBaseResource +} + +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 BackupEnginesClient) 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, "backupengines.BackupEnginesClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupEnginesClient) 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/backupEngines", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupEnginesClient) 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 BackupEnginesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []BackupEngineBaseResource `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, "backupengines.BackupEnginesClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupEnginesClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, BackupEngineBaseResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupEnginesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate BackupEngineBaseResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]BackupEngineBaseResource, 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/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_azurebackupserverengine.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_azurebackupserverengine.go new file mode 100644 index 00000000000..f26cf78714f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_azurebackupserverengine.go @@ -0,0 +1,73 @@ +package backupengines + +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 _ BackupEngineBase = AzureBackupServerEngine{} + +type AzureBackupServerEngine struct { + + // Fields inherited from BackupEngineBase + + AzureBackupAgentVersion *string `json:"azureBackupAgentVersion,omitempty"` + BackupEngineId *string `json:"backupEngineId,omitempty"` + BackupEngineState *string `json:"backupEngineState,omitempty"` + BackupEngineType BackupEngineType `json:"backupEngineType"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + DpmVersion *string `json:"dpmVersion,omitempty"` + ExtendedInfo *BackupEngineExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + IsAzureBackupAgentUpgradeAvailable *bool `json:"isAzureBackupAgentUpgradeAvailable,omitempty"` + IsDpmUpgradeAvailable *bool `json:"isDpmUpgradeAvailable,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureBackupServerEngine) BackupEngineBase() BaseBackupEngineBaseImpl { + return BaseBackupEngineBaseImpl{ + AzureBackupAgentVersion: s.AzureBackupAgentVersion, + BackupEngineId: s.BackupEngineId, + BackupEngineState: s.BackupEngineState, + BackupEngineType: s.BackupEngineType, + BackupManagementType: s.BackupManagementType, + CanReRegister: s.CanReRegister, + DpmVersion: s.DpmVersion, + ExtendedInfo: s.ExtendedInfo, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + IsAzureBackupAgentUpgradeAvailable: s.IsAzureBackupAgentUpgradeAvailable, + IsDpmUpgradeAvailable: s.IsDpmUpgradeAvailable, + RegistrationStatus: s.RegistrationStatus, + } +} + +var _ json.Marshaler = AzureBackupServerEngine{} + +func (s AzureBackupServerEngine) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerEngine + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerEngine: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerEngine: %+v", err) + } + + decoded["backupEngineType"] = "AzureBackupServerEngine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerEngine: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupenginebase.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupenginebase.go new file mode 100644 index 00000000000..d50c4e514ea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupenginebase.go @@ -0,0 +1,95 @@ +package backupengines + +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 BackupEngineBase interface { + BackupEngineBase() BaseBackupEngineBaseImpl +} + +var _ BackupEngineBase = BaseBackupEngineBaseImpl{} + +type BaseBackupEngineBaseImpl struct { + AzureBackupAgentVersion *string `json:"azureBackupAgentVersion,omitempty"` + BackupEngineId *string `json:"backupEngineId,omitempty"` + BackupEngineState *string `json:"backupEngineState,omitempty"` + BackupEngineType BackupEngineType `json:"backupEngineType"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + DpmVersion *string `json:"dpmVersion,omitempty"` + ExtendedInfo *BackupEngineExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + IsAzureBackupAgentUpgradeAvailable *bool `json:"isAzureBackupAgentUpgradeAvailable,omitempty"` + IsDpmUpgradeAvailable *bool `json:"isDpmUpgradeAvailable,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s BaseBackupEngineBaseImpl) BackupEngineBase() BaseBackupEngineBaseImpl { + return s +} + +var _ BackupEngineBase = RawBackupEngineBaseImpl{} + +// RawBackupEngineBaseImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawBackupEngineBaseImpl struct { + backupEngineBase BaseBackupEngineBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawBackupEngineBaseImpl) BackupEngineBase() BaseBackupEngineBaseImpl { + return s.backupEngineBase +} + +func UnmarshalBackupEngineBaseImplementation(input []byte) (BackupEngineBase, 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 BackupEngineBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["backupEngineType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureBackupServerEngine") { + var out AzureBackupServerEngine + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerEngine: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DpmBackupEngine") { + var out DpmBackupEngine + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmBackupEngine: %+v", err) + } + return out, nil + } + + var parent BaseBackupEngineBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseBackupEngineBaseImpl: %+v", err) + } + + return RawBackupEngineBaseImpl{ + backupEngineBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupenginebaseresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupenginebaseresource.go new file mode 100644 index 00000000000..6dff3b7f9a6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupenginebaseresource.go @@ -0,0 +1,57 @@ +package backupengines + +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 BackupEngineBaseResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties BackupEngineBase `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &BackupEngineBaseResource{} + +func (s *BackupEngineBaseResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 BackupEngineBaseResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalBackupEngineBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'BackupEngineBaseResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupengineextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupengineextendedinfo.go new file mode 100644 index 00000000000..cf19ed8a259 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_backupengineextendedinfo.go @@ -0,0 +1,33 @@ +package backupengines + +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 BackupEngineExtendedInfo struct { + AvailableDiskSpace *float64 `json:"availableDiskSpace,omitempty"` + AzureProtectedInstances *int64 `json:"azureProtectedInstances,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + DiskCount *int64 `json:"diskCount,omitempty"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ProtectedServersCount *int64 `json:"protectedServersCount,omitempty"` + RefreshedAt *string `json:"refreshedAt,omitempty"` + UsedDiskSpace *float64 `json:"usedDiskSpace,omitempty"` +} + +func (o *BackupEngineExtendedInfo) GetRefreshedAtAsTime() (*time.Time, error) { + if o.RefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupEngineExtendedInfo) SetRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RefreshedAt = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_dpmbackupengine.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_dpmbackupengine.go new file mode 100644 index 00000000000..c2ea1c634f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/model_dpmbackupengine.go @@ -0,0 +1,73 @@ +package backupengines + +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 _ BackupEngineBase = DpmBackupEngine{} + +type DpmBackupEngine struct { + + // Fields inherited from BackupEngineBase + + AzureBackupAgentVersion *string `json:"azureBackupAgentVersion,omitempty"` + BackupEngineId *string `json:"backupEngineId,omitempty"` + BackupEngineState *string `json:"backupEngineState,omitempty"` + BackupEngineType BackupEngineType `json:"backupEngineType"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + DpmVersion *string `json:"dpmVersion,omitempty"` + ExtendedInfo *BackupEngineExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + IsAzureBackupAgentUpgradeAvailable *bool `json:"isAzureBackupAgentUpgradeAvailable,omitempty"` + IsDpmUpgradeAvailable *bool `json:"isDpmUpgradeAvailable,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s DpmBackupEngine) BackupEngineBase() BaseBackupEngineBaseImpl { + return BaseBackupEngineBaseImpl{ + AzureBackupAgentVersion: s.AzureBackupAgentVersion, + BackupEngineId: s.BackupEngineId, + BackupEngineState: s.BackupEngineState, + BackupEngineType: s.BackupEngineType, + BackupManagementType: s.BackupManagementType, + CanReRegister: s.CanReRegister, + DpmVersion: s.DpmVersion, + ExtendedInfo: s.ExtendedInfo, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + IsAzureBackupAgentUpgradeAvailable: s.IsAzureBackupAgentUpgradeAvailable, + IsDpmUpgradeAvailable: s.IsDpmUpgradeAvailable, + RegistrationStatus: s.RegistrationStatus, + } +} + +var _ json.Marshaler = DpmBackupEngine{} + +func (s DpmBackupEngine) MarshalJSON() ([]byte, error) { + type wrapper DpmBackupEngine + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmBackupEngine: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmBackupEngine: %+v", err) + } + + decoded["backupEngineType"] = "DpmBackupEngine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmBackupEngine: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/predicates.go new file mode 100644 index 00000000000..5d9e2bfd1f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/predicates.go @@ -0,0 +1,37 @@ +package backupengines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupEngineBaseResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p BackupEngineBaseResourceOperationPredicate) Matches(input BackupEngineBaseResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/version.go new file mode 100644 index 00000000000..8c5f5d974fe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupengines/version.go @@ -0,0 +1,10 @@ +package backupengines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupengines/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/README.md new file mode 100644 index 00000000000..f7eefcfe175 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs` Documentation + +The `backupjobs` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupjobs" +``` + + +### Client Initialization + +```go +client := backupjobs.NewBackupJobsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupJobsClient.List` + +```go +ctx := context.TODO() +id := backupjobs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, backupjobs.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupjobs.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/client.go new file mode 100644 index 00000000000..79d95da7560 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/client.go @@ -0,0 +1,18 @@ +package backupjobs + +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 BackupJobsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupJobsClientWithBaseURI(endpoint string) BackupJobsClient { + return BackupJobsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/constants.go new file mode 100644 index 00000000000..320bbc57e71 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/constants.go @@ -0,0 +1,225 @@ +package backupjobs + +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 JobSupportedAction string + +const ( + JobSupportedActionCancellable JobSupportedAction = "Cancellable" + JobSupportedActionInvalid JobSupportedAction = "Invalid" + JobSupportedActionRetriable JobSupportedAction = "Retriable" +) + +func PossibleValuesForJobSupportedAction() []string { + return []string{ + string(JobSupportedActionCancellable), + string(JobSupportedActionInvalid), + string(JobSupportedActionRetriable), + } +} + +func parseJobSupportedAction(input string) (*JobSupportedAction, error) { + vals := map[string]JobSupportedAction{ + "cancellable": JobSupportedActionCancellable, + "invalid": JobSupportedActionInvalid, + "retriable": JobSupportedActionRetriable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobSupportedAction(input) + return &out, nil +} + +type MabServerType string + +const ( + MabServerTypeAzureBackupServerContainer MabServerType = "AzureBackupServerContainer" + MabServerTypeAzureSqlContainer MabServerType = "AzureSqlContainer" + MabServerTypeCluster MabServerType = "Cluster" + MabServerTypeDPMContainer MabServerType = "DPMContainer" + MabServerTypeGenericContainer MabServerType = "GenericContainer" + MabServerTypeIaasVMContainer MabServerType = "IaasVMContainer" + MabServerTypeIaasVMServiceContainer MabServerType = "IaasVMServiceContainer" + MabServerTypeInvalid MabServerType = "Invalid" + MabServerTypeMABContainer MabServerType = "MABContainer" + MabServerTypeSQLAGWorkLoadContainer MabServerType = "SQLAGWorkLoadContainer" + MabServerTypeStorageContainer MabServerType = "StorageContainer" + MabServerTypeUnknown MabServerType = "Unknown" + MabServerTypeVCenter MabServerType = "VCenter" + MabServerTypeVMAppContainer MabServerType = "VMAppContainer" + MabServerTypeWindows MabServerType = "Windows" +) + +func PossibleValuesForMabServerType() []string { + return []string{ + string(MabServerTypeAzureBackupServerContainer), + string(MabServerTypeAzureSqlContainer), + string(MabServerTypeCluster), + string(MabServerTypeDPMContainer), + string(MabServerTypeGenericContainer), + string(MabServerTypeIaasVMContainer), + string(MabServerTypeIaasVMServiceContainer), + string(MabServerTypeInvalid), + string(MabServerTypeMABContainer), + string(MabServerTypeSQLAGWorkLoadContainer), + string(MabServerTypeStorageContainer), + string(MabServerTypeUnknown), + string(MabServerTypeVCenter), + string(MabServerTypeVMAppContainer), + string(MabServerTypeWindows), + } +} + +func parseMabServerType(input string) (*MabServerType, error) { + vals := map[string]MabServerType{ + "azurebackupservercontainer": MabServerTypeAzureBackupServerContainer, + "azuresqlcontainer": MabServerTypeAzureSqlContainer, + "cluster": MabServerTypeCluster, + "dpmcontainer": MabServerTypeDPMContainer, + "genericcontainer": MabServerTypeGenericContainer, + "iaasvmcontainer": MabServerTypeIaasVMContainer, + "iaasvmservicecontainer": MabServerTypeIaasVMServiceContainer, + "invalid": MabServerTypeInvalid, + "mabcontainer": MabServerTypeMABContainer, + "sqlagworkloadcontainer": MabServerTypeSQLAGWorkLoadContainer, + "storagecontainer": MabServerTypeStorageContainer, + "unknown": MabServerTypeUnknown, + "vcenter": MabServerTypeVCenter, + "vmappcontainer": MabServerTypeVMAppContainer, + "windows": MabServerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MabServerType(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" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + 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(WorkloadTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "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/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/id_vault.go new file mode 100644 index 00000000000..c43726a1b29 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/id_vault.go @@ -0,0 +1,130 @@ +package backupjobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/id_vault_test.go new file mode 100644 index 00000000000..72914eb70bb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/id_vault_test.go @@ -0,0 +1,282 @@ +package backupjobs + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/method_list_autorest.go new file mode 100644 index 00000000000..81e1c19dc60 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupjobs + +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 *[]JobResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []JobResource +} + +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 BackupJobsClient) 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, "backupjobs.BackupJobsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupJobsClient) 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/backupJobs", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupJobsClient) 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 BackupJobsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []JobResource `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, "backupjobs.BackupJobsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupJobsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, JobResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupJobsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate JobResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]JobResource, 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/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmerrorinfo.go new file mode 100644 index 00000000000..d9fe5b31814 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmerrorinfo.go @@ -0,0 +1,11 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + ErrorTitle *string `json:"errorTitle,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjob.go new file mode 100644 index 00000000000..332abb0f332 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjob.go @@ -0,0 +1,97 @@ +package backupjobs + +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 _ Job = AzureIaaSVMJob{} + +type AzureIaaSVMJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureIaaSVMErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureIaaSVMJobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered *bool `json:"isUserTriggered,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s AzureIaaSVMJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *AzureIaaSVMJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureIaaSVMJob{} + +func (s AzureIaaSVMJob) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMJob: %+v", err) + } + + decoded["jobType"] = "AzureIaaSVMJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobextendedinfo.go new file mode 100644 index 00000000000..8fd0ef0f439 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobextendedinfo.go @@ -0,0 +1,13 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + EstimatedRemainingDuration *string `json:"estimatedRemainingDuration,omitempty"` + InternalPropertyBag *map[string]string `json:"internalPropertyBag,omitempty"` + ProgressPercentage *float64 `json:"progressPercentage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureIaaSVMJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobtaskdetails.go new file mode 100644 index 00000000000..dad4a07a3ba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobtaskdetails.go @@ -0,0 +1,45 @@ +package backupjobs + +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 AzureIaaSVMJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + InstanceId *string `json:"instanceId,omitempty"` + ProgressPercentage *float64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskExecutionDetails *string `json:"taskExecutionDetails,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *AzureIaaSVMJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobv2.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobv2.go new file mode 100644 index 00000000000..fa168e3c706 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureiaasvmjobv2.go @@ -0,0 +1,96 @@ +package backupjobs + +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 _ Job = AzureIaaSVMJobV2{} + +type AzureIaaSVMJobV2 struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureIaaSVMErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureIaaSVMJobExtendedInfo `json:"extendedInfo,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s AzureIaaSVMJobV2) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *AzureIaaSVMJobV2) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobV2) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJobV2) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobV2) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureIaaSVMJobV2{} + +func (s AzureIaaSVMJobV2) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMJobV2 + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMJobV2: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMJobV2: %+v", err) + } + + decoded["jobType"] = "AzureIaaSVMJobV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMJobV2: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestorageerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestorageerrorinfo.go new file mode 100644 index 00000000000..9a52a41965c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestorageerrorinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejob.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejob.go new file mode 100644 index 00000000000..bc6959e39ec --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejob.go @@ -0,0 +1,97 @@ +package backupjobs + +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 _ Job = AzureStorageJob{} + +type AzureStorageJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureStorageErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureStorageJobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered *bool `json:"isUserTriggered,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s AzureStorageJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *AzureStorageJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureStorageJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureStorageJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureStorageJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureStorageJob{} + +func (s AzureStorageJob) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageJob: %+v", err) + } + + decoded["jobType"] = "AzureStorageJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejobextendedinfo.go new file mode 100644 index 00000000000..22b7d4107d7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejobextendedinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureStorageJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejobtaskdetails.go new file mode 100644 index 00000000000..9b9bb298d99 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azurestoragejobtaskdetails.go @@ -0,0 +1,9 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageJobTaskDetails struct { + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloaderrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloaderrorinfo.go new file mode 100644 index 00000000000..edc953a540c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloaderrorinfo.go @@ -0,0 +1,12 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadErrorInfo struct { + AdditionalDetails *string `json:"additionalDetails,omitempty"` + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + ErrorTitle *string `json:"errorTitle,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjob.go new file mode 100644 index 00000000000..27044486fd1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjob.go @@ -0,0 +1,95 @@ +package backupjobs + +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 _ Job = AzureWorkloadJob{} + +type AzureWorkloadJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureWorkloadErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureWorkloadJobExtendedInfo `json:"extendedInfo,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s AzureWorkloadJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *AzureWorkloadJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureWorkloadJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureWorkloadJob{} + +func (s AzureWorkloadJob) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadJob: %+v", err) + } + + decoded["jobType"] = "AzureWorkloadJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjobextendedinfo.go new file mode 100644 index 00000000000..160a414f7f3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjobextendedinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureWorkloadJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjobtaskdetails.go new file mode 100644 index 00000000000..0757ffec0fb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_azureworkloadjobtaskdetails.go @@ -0,0 +1,9 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadJobTaskDetails struct { + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmerrorinfo.go new file mode 100644 index 00000000000..091cf8f3157 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmerrorinfo.go @@ -0,0 +1,9 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmErrorInfo struct { + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjob.go new file mode 100644 index 00000000000..39f8d964bc0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjob.go @@ -0,0 +1,98 @@ +package backupjobs + +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 _ Job = DpmJob{} + +type DpmJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + ContainerType *string `json:"containerType,omitempty"` + DpmServerName *string `json:"dpmServerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]DpmErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *DpmJobExtendedInfo `json:"extendedInfo,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s DpmJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *DpmJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DpmJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = DpmJob{} + +func (s DpmJob) MarshalJSON() ([]byte, error) { + type wrapper DpmJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmJob: %+v", err) + } + + decoded["jobType"] = "DpmJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjobextendedinfo.go new file mode 100644 index 00000000000..6d4f63a2296 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjobextendedinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]DpmJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjobtaskdetails.go new file mode 100644 index 00000000000..ebf8a7cd691 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_dpmjobtaskdetails.go @@ -0,0 +1,42 @@ +package backupjobs + +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 DpmJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *DpmJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DpmJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_job.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_job.go new file mode 100644 index 00000000000..26c40f95602 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_job.go @@ -0,0 +1,130 @@ +package backupjobs + +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 Job interface { + Job() BaseJobImpl +} + +var _ Job = BaseJobImpl{} + +type BaseJobImpl struct { + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s BaseJobImpl) Job() BaseJobImpl { + return s +} + +var _ Job = RawJobImpl{} + +// RawJobImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawJobImpl struct { + job BaseJobImpl + Type string + Values map[string]interface{} +} + +func (s RawJobImpl) Job() BaseJobImpl { + return s.job +} + +func UnmarshalJobImplementation(input []byte) (Job, 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 Job into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureIaaSVMJob") { + var out AzureIaaSVMJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMJobV2") { + var out AzureIaaSVMJobV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMJobV2: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureStorageJob") { + var out AzureStorageJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadJob") { + var out AzureWorkloadJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DpmJob") { + var out DpmJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MabJob") { + var out MabJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VaultJob") { + var out VaultJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VaultJob: %+v", err) + } + return out, nil + } + + var parent BaseJobImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobImpl: %+v", err) + } + + return RawJobImpl{ + job: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_jobresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_jobresource.go new file mode 100644 index 00000000000..fd6239c0f29 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_jobresource.go @@ -0,0 +1,57 @@ +package backupjobs + +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 JobResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties Job `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &JobResource{} + +func (s *JobResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 JobResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalJobImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'JobResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_maberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_maberrorinfo.go new file mode 100644 index 00000000000..9c3668d2bd5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_maberrorinfo.go @@ -0,0 +1,9 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabErrorInfo struct { + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjob.go new file mode 100644 index 00000000000..5a734c60a23 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjob.go @@ -0,0 +1,97 @@ +package backupjobs + +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 _ Job = MabJob{} + +type MabJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]MabErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *MabJobExtendedInfo `json:"extendedInfo,omitempty"` + MabServerName *string `json:"mabServerName,omitempty"` + MabServerType *MabServerType `json:"mabServerType,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s MabJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *MabJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MabJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = MabJob{} + +func (s MabJob) MarshalJSON() ([]byte, error) { + type wrapper MabJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabJob: %+v", err) + } + + decoded["jobType"] = "MabJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjobextendedinfo.go new file mode 100644 index 00000000000..eb61f914ed9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjobextendedinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]MabJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjobtaskdetails.go new file mode 100644 index 00000000000..15efde49be8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_mabjobtaskdetails.go @@ -0,0 +1,42 @@ +package backupjobs + +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 MabJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *MabJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MabJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjob.go new file mode 100644 index 00000000000..725f23987e3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjob.go @@ -0,0 +1,94 @@ +package backupjobs + +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 _ Job = VaultJob{} + +type VaultJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]VaultJobErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *VaultJobExtendedInfo `json:"extendedInfo,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s VaultJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *VaultJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *VaultJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = VaultJob{} + +func (s VaultJob) MarshalJSON() ([]byte, error) { + type wrapper VaultJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VaultJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VaultJob: %+v", err) + } + + decoded["jobType"] = "VaultJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VaultJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjoberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjoberrorinfo.go new file mode 100644 index 00000000000..cca822b6d80 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjoberrorinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultJobErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjobextendedinfo.go new file mode 100644 index 00000000000..ad9c628fcf1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/model_vaultjobextendedinfo.go @@ -0,0 +1,8 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultJobExtendedInfo struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/predicates.go new file mode 100644 index 00000000000..f8942840380 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/predicates.go @@ -0,0 +1,37 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p JobResourceOperationPredicate) Matches(input JobResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/version.go new file mode 100644 index 00000000000..658e69c62ad --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs/version.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupjobs/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/README.md new file mode 100644 index 00000000000..93e0c3c84cb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies` Documentation + +The `backuppolicies` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backuppolicies" +``` + + +### Client Initialization + +```go +client := backuppolicies.NewBackupPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupPoliciesClient.List` + +```go +ctx := context.TODO() +id := backuppolicies.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, backuppolicies.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backuppolicies.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/client.go new file mode 100644 index 00000000000..c8b3aad1674 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/client.go @@ -0,0 +1,18 @@ +package backuppolicies + +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 BackupPoliciesClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupPoliciesClientWithBaseURI(endpoint string) BackupPoliciesClient { + return BackupPoliciesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/constants.go new file mode 100644 index 00000000000..43b763cad54 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/constants.go @@ -0,0 +1,460 @@ +package backuppolicies + +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 IaasVMSnapshotConsistencyType string + +const ( + IaasVMSnapshotConsistencyTypeOnlyCrashConsistent IaasVMSnapshotConsistencyType = "OnlyCrashConsistent" +) + +func PossibleValuesForIaasVMSnapshotConsistencyType() []string { + return []string{ + string(IaasVMSnapshotConsistencyTypeOnlyCrashConsistent), + } +} + +func parseIaasVMSnapshotConsistencyType(input string) (*IaasVMSnapshotConsistencyType, error) { + vals := map[string]IaasVMSnapshotConsistencyType{ + "onlycrashconsistent": IaasVMSnapshotConsistencyTypeOnlyCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IaasVMSnapshotConsistencyType(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" + PolicyTypeSnapshotCopyOnlyFull PolicyType = "SnapshotCopyOnlyFull" + PolicyTypeSnapshotFull PolicyType = "SnapshotFull" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeCopyOnlyFull), + string(PolicyTypeDifferential), + string(PolicyTypeFull), + string(PolicyTypeIncremental), + string(PolicyTypeInvalid), + string(PolicyTypeLog), + string(PolicyTypeSnapshotCopyOnlyFull), + string(PolicyTypeSnapshotFull), + } +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "copyonlyfull": PolicyTypeCopyOnlyFull, + "differential": PolicyTypeDifferential, + "full": PolicyTypeFull, + "incremental": PolicyTypeIncremental, + "invalid": PolicyTypeInvalid, + "log": PolicyTypeLog, + "snapshotcopyonlyfull": PolicyTypeSnapshotCopyOnlyFull, + "snapshotfull": PolicyTypeSnapshotFull, + } + 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" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + 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(WorkloadTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/id_vault.go new file mode 100644 index 00000000000..2ba1cb260f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/id_vault.go @@ -0,0 +1,130 @@ +package backuppolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/id_vault_test.go new file mode 100644 index 00000000000..bf2c587d37f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/id_vault_test.go @@ -0,0 +1,282 @@ +package backuppolicies + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/method_list_autorest.go new file mode 100644 index 00000000000..094b05fed04 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/method_list_autorest.go @@ -0,0 +1,215 @@ +package backuppolicies + +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 *[]ProtectionPolicyResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectionPolicyResource +} + +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 BackupPoliciesClient) 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, "backuppolicies.BackupPoliciesClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupPoliciesClient) 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/backupPolicies", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupPoliciesClient) 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 BackupPoliciesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectionPolicyResource `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, "backuppolicies.BackupPoliciesClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupPoliciesClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectionPolicyResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ProtectionPolicyResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectionPolicyResource, 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azurefileshareprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azurefileshareprotectionpolicy.go new file mode 100644 index 00000000000..542cb00482a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azurefileshareprotectionpolicy.go @@ -0,0 +1,104 @@ +package backuppolicies + +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"` + VaultRetentionPolicy *VaultRetentionPolicy `json:"vaultRetentionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureFileShareProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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 { + var decoded struct { + TimeZone *string `json:"timeZone,omitempty"` + VaultRetentionPolicy *VaultRetentionPolicy `json:"vaultRetentionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.TimeZone = decoded.TimeZone + s.VaultRetentionPolicy = decoded.VaultRetentionPolicy + s.WorkLoadType = decoded.WorkLoadType + s.BackupManagementType = decoded.BackupManagementType + 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 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azureiaasvmprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azureiaasvmprotectionpolicy.go new file mode 100644 index 00000000000..f5832946dc9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azureiaasvmprotectionpolicy.go @@ -0,0 +1,113 @@ +package backuppolicies + +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"` + SnapshotConsistencyType *IaasVMSnapshotConsistencyType `json:"snapshotConsistencyType,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureIaaSVMProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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 { + var decoded struct { + InstantRPDetails *InstantRPAdditionalDetails `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + PolicyType *IAASVMPolicyType `json:"policyType,omitempty"` + SnapshotConsistencyType *IaasVMSnapshotConsistencyType `json:"snapshotConsistencyType,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.InstantRPDetails = decoded.InstantRPDetails + s.InstantRpRetentionRangeInDays = decoded.InstantRpRetentionRangeInDays + s.PolicyType = decoded.PolicyType + s.SnapshotConsistencyType = decoded.SnapshotConsistencyType + s.TieringPolicy = decoded.TieringPolicy + s.TimeZone = decoded.TimeZone + s.BackupManagementType = decoded.BackupManagementType + 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 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azuresqlprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azuresqlprotectionpolicy.go new file mode 100644 index 00000000000..320c7332b72 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azuresqlprotectionpolicy.go @@ -0,0 +1,86 @@ +package backuppolicies + +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 + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureSqlProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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 { + var decoded struct { + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BackupManagementType = decoded.BackupManagementType + 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go new file mode 100644 index 00000000000..03faa82d9e8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go @@ -0,0 +1,57 @@ +package backuppolicies + +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 + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureVMWorkloadProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyretentionformat.go new file mode 100644 index 00000000000..1c5f0a22c9b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyretentionformat.go @@ -0,0 +1,8 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyretentionschedule.go new file mode 100644 index 00000000000..581a2b22ed5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyretentionschedule.go @@ -0,0 +1,9 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyschedule.go new file mode 100644 index 00000000000..34b307b9262 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_dailyschedule.go @@ -0,0 +1,8 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_day.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_day.go new file mode 100644 index 00000000000..c46c7f57129 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_day.go @@ -0,0 +1,9 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_genericprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_genericprotectionpolicy.go new file mode 100644 index 00000000000..e38a579d407 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_genericprotectionpolicy.go @@ -0,0 +1,56 @@ +package backuppolicies + +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 + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s GenericProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_hourlyschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_hourlyschedule.go new file mode 100644 index 00000000000..f9f1a5a1d3c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_hourlyschedule.go @@ -0,0 +1,28 @@ +package backuppolicies + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_instantrpadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_instantrpadditionaldetails.go new file mode 100644 index 00000000000..f70f265dc45 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_instantrpadditionaldetails.go @@ -0,0 +1,9 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_logschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_logschedulepolicy.go new file mode 100644 index 00000000000..91ef6a09dba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_logschedulepolicy.go @@ -0,0 +1,50 @@ +package backuppolicies + +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 + + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s LogSchedulePolicy) SchedulePolicy() BaseSchedulePolicyImpl { + return BaseSchedulePolicyImpl{ + SchedulePolicyType: s.SchedulePolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_longtermretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_longtermretentionpolicy.go new file mode 100644 index 00000000000..5fac545d5fa --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_longtermretentionpolicy.go @@ -0,0 +1,53 @@ +package backuppolicies + +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 + + RetentionPolicyType string `json:"retentionPolicyType"` +} + +func (s LongTermRetentionPolicy) RetentionPolicy() BaseRetentionPolicyImpl { + return BaseRetentionPolicyImpl{ + RetentionPolicyType: s.RetentionPolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_longtermschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_longtermschedulepolicy.go new file mode 100644 index 00000000000..27e1138014d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_longtermschedulepolicy.go @@ -0,0 +1,49 @@ +package backuppolicies + +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 + + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s LongTermSchedulePolicy) SchedulePolicy() BaseSchedulePolicyImpl { + return BaseSchedulePolicyImpl{ + SchedulePolicyType: s.SchedulePolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_mabprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_mabprotectionpolicy.go new file mode 100644 index 00000000000..7a45376edc6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_mabprotectionpolicy.go @@ -0,0 +1,95 @@ +package backuppolicies + +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 + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s MabProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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 { + var decoded struct { + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BackupManagementType = decoded.BackupManagementType + 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_monthlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_monthlyretentionschedule.go new file mode 100644 index 00000000000..8b8118cc9ee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_monthlyretentionschedule.go @@ -0,0 +1,12 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_protectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_protectionpolicy.go new file mode 100644 index 00000000000..bbe9733f81c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_protectionpolicy.go @@ -0,0 +1,117 @@ +package backuppolicies + +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 { + ProtectionPolicy() BaseProtectionPolicyImpl +} + +var _ ProtectionPolicy = BaseProtectionPolicyImpl{} + +type BaseProtectionPolicyImpl struct { + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s BaseProtectionPolicyImpl) ProtectionPolicy() BaseProtectionPolicyImpl { + return s +} + +var _ ProtectionPolicy = RawProtectionPolicyImpl{} + +// RawProtectionPolicyImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionPolicyImpl struct { + protectionPolicy BaseProtectionPolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionPolicyImpl) ProtectionPolicy() BaseProtectionPolicyImpl { + return s.protectionPolicy +} + +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) + } + + var value string + if v, ok := temp["backupManagementType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseProtectionPolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionPolicyImpl: %+v", err) + } + + return RawProtectionPolicyImpl{ + protectionPolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_protectionpolicyresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_protectionpolicyresource.go new file mode 100644 index 00000000000..07eb0540555 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_protectionpolicyresource.go @@ -0,0 +1,57 @@ +package backuppolicies + +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 { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_retentionduration.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_retentionduration.go new file mode 100644 index 00000000000..60ecd1bea07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_retentionduration.go @@ -0,0 +1,9 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_retentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_retentionpolicy.go new file mode 100644 index 00000000000..4e241b3db7c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_retentionpolicy.go @@ -0,0 +1,83 @@ +package backuppolicies + +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 { + RetentionPolicy() BaseRetentionPolicyImpl +} + +var _ RetentionPolicy = BaseRetentionPolicyImpl{} + +type BaseRetentionPolicyImpl struct { + RetentionPolicyType string `json:"retentionPolicyType"` +} + +func (s BaseRetentionPolicyImpl) RetentionPolicy() BaseRetentionPolicyImpl { + return s +} + +var _ RetentionPolicy = RawRetentionPolicyImpl{} + +// RawRetentionPolicyImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRetentionPolicyImpl struct { + retentionPolicy BaseRetentionPolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawRetentionPolicyImpl) RetentionPolicy() BaseRetentionPolicyImpl { + return s.retentionPolicy +} + +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) + } + + var value string + if v, ok := temp["retentionPolicyType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseRetentionPolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRetentionPolicyImpl: %+v", err) + } + + return RawRetentionPolicyImpl{ + retentionPolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_schedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_schedulepolicy.go new file mode 100644 index 00000000000..acbb07f9d24 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_schedulepolicy.go @@ -0,0 +1,99 @@ +package backuppolicies + +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 { + SchedulePolicy() BaseSchedulePolicyImpl +} + +var _ SchedulePolicy = BaseSchedulePolicyImpl{} + +type BaseSchedulePolicyImpl struct { + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s BaseSchedulePolicyImpl) SchedulePolicy() BaseSchedulePolicyImpl { + return s +} + +var _ SchedulePolicy = RawSchedulePolicyImpl{} + +// RawSchedulePolicyImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSchedulePolicyImpl struct { + schedulePolicy BaseSchedulePolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawSchedulePolicyImpl) SchedulePolicy() BaseSchedulePolicyImpl { + return s.schedulePolicy +} + +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) + } + + var value string + if v, ok := temp["schedulePolicyType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseSchedulePolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSchedulePolicyImpl: %+v", err) + } + + return RawSchedulePolicyImpl{ + schedulePolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_settings.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_settings.go new file mode 100644 index 00000000000..c59cc13bdbe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_settings.go @@ -0,0 +1,10 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleretentionpolicy.go new file mode 100644 index 00000000000..165cbbda9a5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleretentionpolicy.go @@ -0,0 +1,50 @@ +package backuppolicies + +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 + + RetentionPolicyType string `json:"retentionPolicyType"` +} + +func (s SimpleRetentionPolicy) RetentionPolicy() BaseRetentionPolicyImpl { + return BaseRetentionPolicyImpl{ + RetentionPolicyType: s.RetentionPolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleschedulepolicy.go new file mode 100644 index 00000000000..bd4bfbb8a0b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleschedulepolicy.go @@ -0,0 +1,54 @@ +package backuppolicies + +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 + + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s SimpleSchedulePolicy) SchedulePolicy() BaseSchedulePolicyImpl { + return BaseSchedulePolicyImpl{ + SchedulePolicyType: s.SchedulePolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleschedulepolicyv2.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleschedulepolicyv2.go new file mode 100644 index 00000000000..0bf77063df5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_simpleschedulepolicyv2.go @@ -0,0 +1,53 @@ +package backuppolicies + +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 + + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s SimpleSchedulePolicyV2) SchedulePolicy() BaseSchedulePolicyImpl { + return BaseSchedulePolicyImpl{ + SchedulePolicyType: s.SchedulePolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_snapshotbackupadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_snapshotbackupadditionaldetails.go new file mode 100644 index 00000000000..33761b836e4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_snapshotbackupadditionaldetails.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotBackupAdditionalDetails struct { + InstantRPDetails *string `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_subprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_subprotectionpolicy.go new file mode 100644 index 00000000000..aca80b3d511 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_subprotectionpolicy.go @@ -0,0 +1,57 @@ +package backuppolicies + +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"` + SnapshotBackupAdditionalDetails *SnapshotBackupAdditionalDetails `json:"snapshotBackupAdditionalDetails,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` +} + +var _ json.Unmarshaler = &SubProtectionPolicy{} + +func (s *SubProtectionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PolicyType *PolicyType `json:"policyType,omitempty"` + SnapshotBackupAdditionalDetails *SnapshotBackupAdditionalDetails `json:"snapshotBackupAdditionalDetails,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PolicyType = decoded.PolicyType + s.SnapshotBackupAdditionalDetails = decoded.SnapshotBackupAdditionalDetails + 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_tieringpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_tieringpolicy.go new file mode 100644 index 00000000000..6075f6ce494 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_tieringpolicy.go @@ -0,0 +1,10 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..7f80e2e49db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..562196aa29d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_vaultretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_vaultretentionpolicy.go new file mode 100644 index 00000000000..5a2b23bc830 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_vaultretentionpolicy.go @@ -0,0 +1,42 @@ +package backuppolicies + +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 VaultRetentionPolicy struct { + SnapshotRetentionInDays int64 `json:"snapshotRetentionInDays"` + VaultRetention RetentionPolicy `json:"vaultRetention"` +} + +var _ json.Unmarshaler = &VaultRetentionPolicy{} + +func (s *VaultRetentionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded struct { + SnapshotRetentionInDays int64 `json:"snapshotRetentionInDays"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.SnapshotRetentionInDays = decoded.SnapshotRetentionInDays + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling VaultRetentionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["vaultRetention"]; ok { + impl, err := UnmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'VaultRetention' for 'VaultRetentionPolicy': %+v", err) + } + s.VaultRetention = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyretentionformat.go new file mode 100644 index 00000000000..33dbf7e202c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyretentionformat.go @@ -0,0 +1,9 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyretentionschedule.go new file mode 100644 index 00000000000..edfa118dffc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyretentionschedule.go @@ -0,0 +1,10 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyschedule.go new file mode 100644 index 00000000000..93dcb41a53c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_weeklyschedule.go @@ -0,0 +1,9 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_yearlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_yearlyretentionschedule.go new file mode 100644 index 00000000000..f2c784a79d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/model_yearlyretentionschedule.go @@ -0,0 +1,13 @@ +package backuppolicies + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/predicates.go new file mode 100644 index 00000000000..cdc446bbcfb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/predicates.go @@ -0,0 +1,37 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicyResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionPolicyResourceOperationPredicate) Matches(input ProtectionPolicyResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/version.go new file mode 100644 index 00000000000..fb9debaccc1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies/version.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backuppolicies/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/README.md new file mode 100644 index 00000000000..4e54129a808 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems` Documentation + +The `backupprotectableitems` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-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", "vaultName") + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/client.go new file mode 100644 index 00000000000..a30b2396b90 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/constants.go new file mode 100644 index 00000000000..f26199c385d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/constants.go @@ -0,0 +1,107 @@ +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/id_vault.go new file mode 100644 index 00000000000..852c43e2bad --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/id_vault.go @@ -0,0 +1,130 @@ +package backupprotectableitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/id_vault_test.go new file mode 100644 index 00000000000..9f59504b28c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/id_vault_test.go @@ -0,0 +1,282 @@ +package backupprotectableitems + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/method_list_autorest.go new file mode 100644 index 00000000000..7e33743e477 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurefileshareprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurefileshareprotectableitem.go new file mode 100644 index 00000000000..542f5632c6a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurefileshareprotectableitem.go @@ -0,0 +1,60 @@ +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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureFileShareProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go new file mode 100644 index 00000000000..783ca6ce6b1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go @@ -0,0 +1,60 @@ +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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureIaaSClassicComputeVMProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go new file mode 100644 index 00000000000..01d84ff8f83 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go @@ -0,0 +1,60 @@ +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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureIaaSComputeVMProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go new file mode 100644 index 00000000000..985a6a45b79 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go @@ -0,0 +1,66 @@ +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"` + IsProtectable *bool `json:"isProtectable,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go new file mode 100644 index 00000000000..57392564a47 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go @@ -0,0 +1,66 @@ +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"` + IsProtectable *bool `json:"isProtectable,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPAseSystemProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go new file mode 100644 index 00000000000..62eeed455f0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go @@ -0,0 +1,66 @@ +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"` + IsProtectable *bool `json:"isProtectable,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go new file mode 100644 index 00000000000..85180e35a05 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go @@ -0,0 +1,66 @@ +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 = AzureVMWorkloadSAPHanaDBInstance{} + +type AzureVMWorkloadSAPHanaDBInstance struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaDBInstance) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDBInstance{} + +func (s AzureVMWorkloadSAPHanaDBInstance) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDBInstance + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDBInstance: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDBInstance: %+v", err) + } + + decoded["protectableItemType"] = "SAPHanaDBInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDBInstance: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go new file mode 100644 index 00000000000..946c7b496dc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go @@ -0,0 +1,66 @@ +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 = AzureVMWorkloadSAPHanaHSRProtectableItem{} + +type AzureVMWorkloadSAPHanaHSRProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaHSRProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaHSRProtectableItem{} + +func (s AzureVMWorkloadSAPHanaHSRProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaHSRProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaHSRProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaHSRProtectableItem: %+v", err) + } + + decoded["protectableItemType"] = "HanaHSRContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaHSRProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go new file mode 100644 index 00000000000..95c289b65ad --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go @@ -0,0 +1,66 @@ +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"` + IsProtectable *bool `json:"isProtectable,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaSystemProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go new file mode 100644 index 00000000000..24e77bff5b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go @@ -0,0 +1,67 @@ +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"` + IsProtectable *bool `json:"isProtectable,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSQLAvailabilityGroupProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go new file mode 100644 index 00000000000..581f20e1b17 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go @@ -0,0 +1,66 @@ +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"` + IsProtectable *bool `json:"isProtectable,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSQLDatabaseProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go new file mode 100644 index 00000000000..c166cb7f847 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go @@ -0,0 +1,66 @@ +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"` + IsProtectable *bool `json:"isProtectable,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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSQLInstanceProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_distributednodesinfo.go new file mode 100644 index 00000000000..6e96dfe461c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +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 DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_errordetail.go new file mode 100644 index 00000000000..1c3fd85652e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_errordetail.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 ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_iaasvmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_iaasvmprotectableitem.go new file mode 100644 index 00000000000..17559c25e6d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_iaasvmprotectableitem.go @@ -0,0 +1,60 @@ +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"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s IaaSVMProtectableItem) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return BaseWorkloadProtectableItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectableItemType: s.ProtectableItemType, + ProtectionState: s.ProtectionState, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_prebackupvalidation.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_prebackupvalidation.go new file mode 100644 index 00000000000..955dd612808 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_workloadprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_workloadprotectableitem.go new file mode 100644 index 00000000000..79e222d7430 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_workloadprotectableitem.go @@ -0,0 +1,175 @@ +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 { + WorkloadProtectableItem() BaseWorkloadProtectableItemImpl +} + +var _ WorkloadProtectableItem = BaseWorkloadProtectableItemImpl{} + +type BaseWorkloadProtectableItemImpl struct { + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectableItemType string `json:"protectableItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s BaseWorkloadProtectableItemImpl) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return s +} + +var _ WorkloadProtectableItem = RawWorkloadProtectableItemImpl{} + +// RawWorkloadProtectableItemImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawWorkloadProtectableItemImpl struct { + workloadProtectableItem BaseWorkloadProtectableItemImpl + Type string + Values map[string]interface{} +} + +func (s RawWorkloadProtectableItemImpl) WorkloadProtectableItem() BaseWorkloadProtectableItemImpl { + return s.workloadProtectableItem +} + +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) + } + + var value string + if v, ok := temp["protectableItemType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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, "SAPHanaDBInstance") { + var out AzureVMWorkloadSAPHanaDBInstance + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDBInstance: %+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, "HanaHSRContainer") { + var out AzureVMWorkloadSAPHanaHSRProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaHSRProtectableItem: %+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 + } + + var parent BaseWorkloadProtectableItemImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseWorkloadProtectableItemImpl: %+v", err) + } + + return RawWorkloadProtectableItemImpl{ + workloadProtectableItem: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_workloadprotectableitemresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_workloadprotectableitemresource.go new file mode 100644 index 00000000000..279be78ea02 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/model_workloadprotectableitemresource.go @@ -0,0 +1,57 @@ +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 { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/predicates.go new file mode 100644 index 00000000000..464f22ae33b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/version.go new file mode 100644 index 00000000000..71db14b6b6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems/version.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. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupprotectableitems/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/README.md new file mode 100644 index 00000000000..25f74eb43cf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems` Documentation + +The `backupprotecteditems` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-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", "vaultName") + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/client.go new file mode 100644 index 00000000000..7bb37dd5d36 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/constants.go new file mode 100644 index 00000000000..27b26f2b761 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/constants.go @@ -0,0 +1,389 @@ +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" + DataSourceTypeSAPHanaDBInstance DataSourceType = "SAPHanaDBInstance" + 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(DataSourceTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": DataSourceTypeSAPHanaDBInstance, + "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 ( + ProtectedItemStateBackupsSuspended ProtectedItemState = "BackupsSuspended" + ProtectedItemStateIRPending ProtectedItemState = "IRPending" + ProtectedItemStateInvalid ProtectedItemState = "Invalid" + ProtectedItemStateProtected ProtectedItemState = "Protected" + ProtectedItemStateProtectionError ProtectedItemState = "ProtectionError" + ProtectedItemStateProtectionPaused ProtectedItemState = "ProtectionPaused" + ProtectedItemStateProtectionStopped ProtectedItemState = "ProtectionStopped" +) + +func PossibleValuesForProtectedItemState() []string { + return []string{ + string(ProtectedItemStateBackupsSuspended), + string(ProtectedItemStateIRPending), + string(ProtectedItemStateInvalid), + string(ProtectedItemStateProtected), + string(ProtectedItemStateProtectionError), + string(ProtectedItemStateProtectionPaused), + string(ProtectedItemStateProtectionStopped), + } +} + +func parseProtectedItemState(input string) (*ProtectedItemState, error) { + vals := map[string]ProtectedItemState{ + "backupssuspended": ProtectedItemStateBackupsSuspended, + "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 ( + ProtectionStateBackupsSuspended ProtectionState = "BackupsSuspended" + ProtectionStateIRPending ProtectionState = "IRPending" + ProtectionStateInvalid ProtectionState = "Invalid" + ProtectionStateProtected ProtectionState = "Protected" + ProtectionStateProtectionError ProtectionState = "ProtectionError" + ProtectionStateProtectionPaused ProtectionState = "ProtectionPaused" + ProtectionStateProtectionStopped ProtectionState = "ProtectionStopped" +) + +func PossibleValuesForProtectionState() []string { + return []string{ + string(ProtectionStateBackupsSuspended), + string(ProtectionStateIRPending), + string(ProtectionStateInvalid), + string(ProtectionStateProtected), + string(ProtectionStateProtectionError), + string(ProtectionStateProtectionPaused), + string(ProtectionStateProtectionStopped), + } +} + +func parseProtectionState(input string) (*ProtectionState, error) { + vals := map[string]ProtectionState{ + "backupssuspended": ProtectionStateBackupsSuspended, + "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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/id_vault.go new file mode 100644 index 00000000000..9bab4f55a09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/id_vault.go @@ -0,0 +1,130 @@ +package backupprotecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/id_vault_test.go new file mode 100644 index 00000000000..57ccb03f9af --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/id_vault_test.go @@ -0,0 +1,282 @@ +package backupprotecteditems + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/method_list_autorest.go new file mode 100644 index 00000000000..5b5c8cd79c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurefileshareprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurefileshareprotecteditem.go new file mode 100644 index 00000000000..f912c83a9d5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurefileshareprotecteditem.go @@ -0,0 +1,119 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureFileshareProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go new file mode 100644 index 00000000000..784dbda1d5d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go new file mode 100644 index 00000000000..92d5a3a21a0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go @@ -0,0 +1,124 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureIaaSClassicComputeVMProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go new file mode 100644 index 00000000000..252cd77f99b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go @@ -0,0 +1,124 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureIaaSComputeVMProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasvmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasvmprotecteditem.go new file mode 100644 index 00000000000..0797737c5ca --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasvmprotecteditem.go @@ -0,0 +1,124 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureIaaSVMProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..f9bd89ad856 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azuresqlprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azuresqlprotecteditem.go new file mode 100644 index 00000000000..a07c8b44ee2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azuresqlprotecteditem.go @@ -0,0 +1,115 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureSqlProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go new file mode 100644 index 00000000000..1f95cebc98c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go new file mode 100644 index 00000000000..f9009af809d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go @@ -0,0 +1,126 @@ +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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go new file mode 100644 index 00000000000..4ad1e158847 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go new file mode 100644 index 00000000000..83e91d8a89f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go @@ -0,0 +1,126 @@ +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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPAseDatabaseProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go new file mode 100644 index 00000000000..eac7abbdf01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go @@ -0,0 +1,126 @@ +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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go new file mode 100644 index 00000000000..b2ea4f926ff --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go @@ -0,0 +1,126 @@ +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 = AzureVMWorkloadSAPHanaDBInstanceProtectedItem{} + +type AzureVMWorkloadSAPHanaDBInstanceProtectedItem 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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaDBInstanceProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDBInstanceProtectedItem{} + +func (s AzureVMWorkloadSAPHanaDBInstanceProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDBInstanceProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + decoded["protectedItemType"] = "AzureVmWorkloadSAPHanaDBInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go new file mode 100644 index 00000000000..54b765018f5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go @@ -0,0 +1,126 @@ +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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSQLDatabaseProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_diskexclusionproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_diskexclusionproperties.go new file mode 100644 index 00000000000..f12fc0030e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_distributednodesinfo.go new file mode 100644 index 00000000000..739b4bcf82a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_distributednodesinfo.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 DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_dpmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_dpmprotecteditem.go new file mode 100644 index 00000000000..a6879fabc8c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_dpmprotecteditem.go @@ -0,0 +1,116 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s DPMProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..c28c138b06e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_errordetail.go new file mode 100644 index 00000000000..c55cc388bf9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_extendedproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_extendedproperties.go new file mode 100644 index 00000000000..bd52e28b60e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_genericprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_genericprotecteditem.go new file mode 100644 index 00000000000..3684d9f7e1d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_genericprotecteditem.go @@ -0,0 +1,118 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s GenericProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_kpiresourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_kpiresourcehealthdetails.go new file mode 100644 index 00000000000..42a11e535b9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_mabfilefolderprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_mabfilefolderprotecteditem.go new file mode 100644 index 00000000000..e6e6d98b4ca --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_mabfilefolderprotecteditem.go @@ -0,0 +1,119 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s MabFileFolderProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go new file mode 100644 index 00000000000..30f88b5c2ac --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_protecteditem.go new file mode 100644 index 00000000000..b825095987f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_protecteditem.go @@ -0,0 +1,189 @@ +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 { + ProtectedItem() BaseProtectedItemImpl +} + +var _ ProtectedItem = BaseProtectedItemImpl{} + +type BaseProtectedItemImpl struct { + 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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s BaseProtectedItemImpl) ProtectedItem() BaseProtectedItemImpl { + return s +} + +var _ ProtectedItem = RawProtectedItemImpl{} + +// RawProtectedItemImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectedItemImpl struct { + protectedItem BaseProtectedItemImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectedItemImpl) ProtectedItem() BaseProtectedItemImpl { + return s.protectedItem +} + +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) + } + + var value string + if v, ok := temp["protectedItemType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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, "AzureVmWorkloadSAPHanaDBInstance") { + var out AzureVMWorkloadSAPHanaDBInstanceProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+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 + } + + var parent BaseProtectedItemImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectedItemImpl: %+v", err) + } + + return RawProtectedItemImpl{ + protectedItem: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_protecteditemresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_protecteditemresource.go new file mode 100644 index 00000000000..c0bee8d014a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_protecteditemresource.go @@ -0,0 +1,57 @@ +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 { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_resourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/model_resourcehealthdetails.go new file mode 100644 index 00000000000..34cb35fbf15 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/predicates.go new file mode 100644 index 00000000000..92b0067d35e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/version.go new file mode 100644 index 00000000000..ba7e0e2d189 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems/version.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. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupprotecteditems/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/README.md new file mode 100644 index 00000000000..684125c94ea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers` Documentation + +The `backupprotectioncontainers` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupprotectioncontainers" +``` + + +### Client Initialization + +```go +client := backupprotectioncontainers.NewBackupProtectionContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectionContainersClient.List` + +```go +ctx := context.TODO() +id := backupprotectioncontainers.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, backupprotectioncontainers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotectioncontainers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/client.go new file mode 100644 index 00000000000..80d302c783e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/client.go @@ -0,0 +1,18 @@ +package backupprotectioncontainers + +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 BackupProtectionContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupProtectionContainersClientWithBaseURI(endpoint string) BackupProtectionContainersClient { + return BackupProtectionContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/constants.go new file mode 100644 index 00000000000..72b80d244e7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/constants.go @@ -0,0 +1,332 @@ +package backupprotectioncontainers + +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" + BackupItemTypeSAPHanaDBInstance BackupItemType = "SAPHanaDBInstance" + 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(BackupItemTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": BackupItemTypeSAPHanaDBInstance, + "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 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 ProtectableContainerType string + +const ( + ProtectableContainerTypeAzureBackupServerContainer ProtectableContainerType = "AzureBackupServerContainer" + ProtectableContainerTypeAzureSqlContainer ProtectableContainerType = "AzureSqlContainer" + ProtectableContainerTypeAzureWorkloadContainer ProtectableContainerType = "AzureWorkloadContainer" + ProtectableContainerTypeCluster ProtectableContainerType = "Cluster" + ProtectableContainerTypeDPMContainer ProtectableContainerType = "DPMContainer" + ProtectableContainerTypeGenericContainer ProtectableContainerType = "GenericContainer" + ProtectableContainerTypeIaasVMContainer ProtectableContainerType = "IaasVMContainer" + ProtectableContainerTypeIaasVMServiceContainer ProtectableContainerType = "IaasVMServiceContainer" + ProtectableContainerTypeInvalid ProtectableContainerType = "Invalid" + ProtectableContainerTypeMABContainer ProtectableContainerType = "MABContainer" + ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines ProtectableContainerType = "Microsoft.ClassicCompute/virtualMachines" + ProtectableContainerTypeMicrosoftPointComputeVirtualMachines ProtectableContainerType = "Microsoft.Compute/virtualMachines" + ProtectableContainerTypeSQLAGWorkLoadContainer ProtectableContainerType = "SQLAGWorkLoadContainer" + ProtectableContainerTypeStorageContainer ProtectableContainerType = "StorageContainer" + ProtectableContainerTypeUnknown ProtectableContainerType = "Unknown" + ProtectableContainerTypeVCenter ProtectableContainerType = "VCenter" + ProtectableContainerTypeVMAppContainer ProtectableContainerType = "VMAppContainer" + ProtectableContainerTypeWindows ProtectableContainerType = "Windows" +) + +func PossibleValuesForProtectableContainerType() []string { + return []string{ + string(ProtectableContainerTypeAzureBackupServerContainer), + string(ProtectableContainerTypeAzureSqlContainer), + string(ProtectableContainerTypeAzureWorkloadContainer), + string(ProtectableContainerTypeCluster), + string(ProtectableContainerTypeDPMContainer), + string(ProtectableContainerTypeGenericContainer), + string(ProtectableContainerTypeIaasVMContainer), + string(ProtectableContainerTypeIaasVMServiceContainer), + string(ProtectableContainerTypeInvalid), + string(ProtectableContainerTypeMABContainer), + string(ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ProtectableContainerTypeMicrosoftPointComputeVirtualMachines), + string(ProtectableContainerTypeSQLAGWorkLoadContainer), + string(ProtectableContainerTypeStorageContainer), + string(ProtectableContainerTypeUnknown), + string(ProtectableContainerTypeVCenter), + string(ProtectableContainerTypeVMAppContainer), + string(ProtectableContainerTypeWindows), + } +} + +func parseProtectableContainerType(input string) (*ProtectableContainerType, error) { + vals := map[string]ProtectableContainerType{ + "azurebackupservercontainer": ProtectableContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ProtectableContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ProtectableContainerTypeAzureWorkloadContainer, + "cluster": ProtectableContainerTypeCluster, + "dpmcontainer": ProtectableContainerTypeDPMContainer, + "genericcontainer": ProtectableContainerTypeGenericContainer, + "iaasvmcontainer": ProtectableContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ProtectableContainerTypeIaasVMServiceContainer, + "invalid": ProtectableContainerTypeInvalid, + "mabcontainer": ProtectableContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ProtectableContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ProtectableContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ProtectableContainerTypeStorageContainer, + "unknown": ProtectableContainerTypeUnknown, + "vcenter": ProtectableContainerTypeVCenter, + "vmappcontainer": ProtectableContainerTypeVMAppContainer, + "windows": ProtectableContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectableContainerType(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" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + 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(WorkloadTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/id_vault.go new file mode 100644 index 00000000000..4eb205d2d94 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/id_vault.go @@ -0,0 +1,130 @@ +package backupprotectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/id_vault_test.go new file mode 100644 index 00000000000..65fcd52324e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/id_vault_test.go @@ -0,0 +1,282 @@ +package backupprotectioncontainers + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/method_list_autorest.go new file mode 100644 index 00000000000..2395d76d2f4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupprotectioncontainers + +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 *[]ProtectionContainerResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectionContainerResource +} + +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 BackupProtectionContainersClient) 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, "backupprotectioncontainers.BackupProtectionContainersClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupProtectionContainersClient) 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/backupProtectionContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupProtectionContainersClient) 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 BackupProtectionContainersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectionContainerResource `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, "backupprotectioncontainers.BackupProtectionContainersClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupProtectionContainersClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectionContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupProtectionContainersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ProtectionContainerResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectionContainerResource, 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..5da198a1293 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurebackupservercontainer.go @@ -0,0 +1,67 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureBackupServerContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..aff827df4c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,62 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureIaaSClassicComputeVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..cd56e5eb1bf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,62 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureIaaSComputeVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..ed722014f5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,64 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..2bd62aa48a1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azuresqlcontainer.go @@ -0,0 +1,59 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureSqlContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..efb33d58246 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurestoragecontainer.go @@ -0,0 +1,64 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureStorageContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..6e223755784 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,64 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureVMAppContainerProtectionContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..e540df3877b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureworkloadcontainer.go @@ -0,0 +1,64 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureWorkloadContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..4e6205329b2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..8cff0e16315 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_containeridentityinfo.go @@ -0,0 +1,11 @@ +package backupprotectioncontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..88d6fe5dcf8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +package backupprotectioncontainers + +// 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"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..b344dd4102f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_dpmcontainer.go @@ -0,0 +1,67 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s DpmContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..62c9b305962 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go @@ -0,0 +1,26 @@ +package backupprotectioncontainers + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_errordetail.go new file mode 100644 index 00000000000..86008b3edcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_errordetail.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_genericcontainer.go new file mode 100644 index 00000000000..c912d3229ef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_genericcontainer.go @@ -0,0 +1,61 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s GenericContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..82f18cd823f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..f43a63174a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_iaasvmcontainer.go @@ -0,0 +1,62 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s IaaSVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..93ec19a6ba0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_inquiryinfo.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..f33ed3584b2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_inquiryvalidation.go @@ -0,0 +1,11 @@ +package backupprotectioncontainers + +// 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"` + ProtectableItemCount *interface{} `json:"protectableItemCount,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainer.go new file mode 100644 index 00000000000..806e61770c0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainer.go @@ -0,0 +1,66 @@ +package backupprotectioncontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s MabContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..b23e3796a39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go @@ -0,0 +1,30 @@ +package backupprotectioncontainers + +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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..7c04be9060e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go @@ -0,0 +1,11 @@ +package backupprotectioncontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..cc1f59de216 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_protectioncontainer.go @@ -0,0 +1,168 @@ +package backupprotectioncontainers + +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 { + ProtectionContainer() BaseProtectionContainerImpl +} + +var _ ProtectionContainer = BaseProtectionContainerImpl{} + +type BaseProtectionContainerImpl struct { + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s BaseProtectionContainerImpl) ProtectionContainer() BaseProtectionContainerImpl { + return s +} + +var _ ProtectionContainer = RawProtectionContainerImpl{} + +// RawProtectionContainerImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionContainerImpl struct { + protectionContainer BaseProtectionContainerImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionContainerImpl) ProtectionContainer() BaseProtectionContainerImpl { + return s.protectionContainer +} + +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) + } + + var value string + if v, ok := temp["containerType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseProtectionContainerImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionContainerImpl: %+v", err) + } + + return RawProtectionContainerImpl{ + protectionContainer: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..4972f653359 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_protectioncontainerresource.go @@ -0,0 +1,57 @@ +package backupprotectioncontainers + +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 { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..fd796f17a93 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/model_workloadinquirydetails.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/predicates.go new file mode 100644 index 00000000000..2c7170b0702 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/predicates.go @@ -0,0 +1,37 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerResourceOperationPredicate) Matches(input ProtectionContainerResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/version.go new file mode 100644 index 00000000000..25638d80a91 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers/version.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupprotectioncontainers/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/README.md new file mode 100644 index 00000000000..5dab6a5e51e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent` Documentation + +The `backupprotectionintent` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupprotectionintent" +``` + + +### Client Initialization + +```go +client := backupprotectionintent.NewBackupProtectionIntentClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectionIntentClient.List` + +```go +ctx := context.TODO() +id := backupprotectionintent.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, backupprotectionintent.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotectionintent.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/client.go new file mode 100644 index 00000000000..10dc6db01e1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/client.go @@ -0,0 +1,18 @@ +package backupprotectionintent + +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 BackupProtectionIntentClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupProtectionIntentClientWithBaseURI(endpoint string) BackupProtectionIntentClient { + return BackupProtectionIntentClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/constants.go new file mode 100644 index 00000000000..54a09b9ab92 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/constants.go @@ -0,0 +1,180 @@ +package backupprotectionintent + +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 ProtectionIntentItemType string + +const ( + ProtectionIntentItemTypeAzureResourceItem ProtectionIntentItemType = "AzureResourceItem" + ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadAutoProtectionIntent" + ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadContainerAutoProtectionIntent" + ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadSQLAutoProtectionIntent" + ProtectionIntentItemTypeInvalid ProtectionIntentItemType = "Invalid" + ProtectionIntentItemTypeRecoveryServiceVaultItem ProtectionIntentItemType = "RecoveryServiceVaultItem" +) + +func PossibleValuesForProtectionIntentItemType() []string { + return []string{ + string(ProtectionIntentItemTypeAzureResourceItem), + string(ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent), + string(ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent), + string(ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent), + string(ProtectionIntentItemTypeInvalid), + string(ProtectionIntentItemTypeRecoveryServiceVaultItem), + } +} + +func parseProtectionIntentItemType(input string) (*ProtectionIntentItemType, error) { + vals := map[string]ProtectionIntentItemType{ + "azureresourceitem": ProtectionIntentItemTypeAzureResourceItem, + "azureworkloadautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent, + "azureworkloadcontainerautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent, + "azureworkloadsqlautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent, + "invalid": ProtectionIntentItemTypeInvalid, + "recoveryservicevaultitem": ProtectionIntentItemTypeRecoveryServiceVaultItem, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionIntentItemType(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 +} + +type WorkloadItemType string + +const ( + WorkloadItemTypeInvalid WorkloadItemType = "Invalid" + WorkloadItemTypeSAPAseDatabase WorkloadItemType = "SAPAseDatabase" + WorkloadItemTypeSAPAseSystem WorkloadItemType = "SAPAseSystem" + WorkloadItemTypeSAPHanaDBInstance WorkloadItemType = "SAPHanaDBInstance" + WorkloadItemTypeSAPHanaDatabase WorkloadItemType = "SAPHanaDatabase" + WorkloadItemTypeSAPHanaSystem WorkloadItemType = "SAPHanaSystem" + WorkloadItemTypeSQLDataBase WorkloadItemType = "SQLDataBase" + WorkloadItemTypeSQLInstance WorkloadItemType = "SQLInstance" +) + +func PossibleValuesForWorkloadItemType() []string { + return []string{ + string(WorkloadItemTypeInvalid), + string(WorkloadItemTypeSAPAseDatabase), + string(WorkloadItemTypeSAPAseSystem), + string(WorkloadItemTypeSAPHanaDBInstance), + string(WorkloadItemTypeSAPHanaDatabase), + string(WorkloadItemTypeSAPHanaSystem), + string(WorkloadItemTypeSQLDataBase), + string(WorkloadItemTypeSQLInstance), + } +} + +func parseWorkloadItemType(input string) (*WorkloadItemType, error) { + vals := map[string]WorkloadItemType{ + "invalid": WorkloadItemTypeInvalid, + "sapasedatabase": WorkloadItemTypeSAPAseDatabase, + "sapasesystem": WorkloadItemTypeSAPAseSystem, + "saphanadbinstance": WorkloadItemTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadItemTypeSAPHanaDatabase, + "saphanasystem": WorkloadItemTypeSAPHanaSystem, + "sqldatabase": WorkloadItemTypeSQLDataBase, + "sqlinstance": WorkloadItemTypeSQLInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadItemType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/id_vault.go new file mode 100644 index 00000000000..7e8ee3ec9cc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/id_vault.go @@ -0,0 +1,130 @@ +package backupprotectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/id_vault_test.go new file mode 100644 index 00000000000..827e17ae883 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/id_vault_test.go @@ -0,0 +1,282 @@ +package backupprotectionintent + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/method_list_autorest.go new file mode 100644 index 00000000000..9e4e60e7b48 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupprotectionintent + +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 *[]ProtectionIntentResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectionIntentResource +} + +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 BackupProtectionIntentClient) 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, "backupprotectionintent.BackupProtectionIntentClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupProtectionIntentClient) 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/backupProtectionIntents", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupProtectionIntentClient) 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 BackupProtectionIntentClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectionIntentResource `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, "backupprotectionintent.BackupProtectionIntentClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupProtectionIntentClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectionIntentResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupProtectionIntentClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ProtectionIntentResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectionIntentResource, 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go new file mode 100644 index 00000000000..f3a96053fba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go @@ -0,0 +1,59 @@ +package backupprotectionintent + +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 _ ProtectionIntent = AzureRecoveryServiceVaultProtectionIntent{} + +type AzureRecoveryServiceVaultProtectionIntent struct { + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureRecoveryServiceVaultProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureRecoveryServiceVaultProtectionIntent{} + +func (s AzureRecoveryServiceVaultProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureRecoveryServiceVaultProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "RecoveryServiceVaultItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureresourceprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureresourceprotectionintent.go new file mode 100644 index 00000000000..89e120970bd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureresourceprotectionintent.go @@ -0,0 +1,60 @@ +package backupprotectionintent + +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 _ ProtectionIntent = AzureResourceProtectionIntent{} + +type AzureResourceProtectionIntent struct { + FriendlyName *string `json:"friendlyName,omitempty"` + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureResourceProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureResourceProtectionIntent{} + +func (s AzureResourceProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureResourceProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureResourceProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureResourceProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "AzureResourceItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureResourceProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go new file mode 100644 index 00000000000..c1bbfceb582 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go @@ -0,0 +1,59 @@ +package backupprotectionintent + +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 _ ProtectionIntent = AzureWorkloadAutoProtectionIntent{} + +type AzureWorkloadAutoProtectionIntent struct { + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureWorkloadAutoProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureWorkloadAutoProtectionIntent{} + +func (s AzureWorkloadAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "AzureWorkloadAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go new file mode 100644 index 00000000000..3210b6e43d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go @@ -0,0 +1,59 @@ +package backupprotectionintent + +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 _ ProtectionIntent = AzureWorkloadContainerAutoProtectionIntent{} + +type AzureWorkloadContainerAutoProtectionIntent struct { + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureWorkloadContainerAutoProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureWorkloadContainerAutoProtectionIntent{} + +func (s AzureWorkloadContainerAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainerAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "AzureWorkloadContainerAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go new file mode 100644 index 00000000000..3f18fb6d200 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go @@ -0,0 +1,60 @@ +package backupprotectionintent + +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 _ ProtectionIntent = AzureWorkloadSQLAutoProtectionIntent{} + +type AzureWorkloadSQLAutoProtectionIntent struct { + WorkloadItemType *WorkloadItemType `json:"workloadItemType,omitempty"` + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureWorkloadSQLAutoProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureWorkloadSQLAutoProtectionIntent{} + +func (s AzureWorkloadSQLAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "AzureWorkloadSQLAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_protectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_protectionintent.go new file mode 100644 index 00000000000..c7eab3c3a81 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_protectionintent.go @@ -0,0 +1,112 @@ +package backupprotectionintent + +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 ProtectionIntent interface { + ProtectionIntent() BaseProtectionIntentImpl +} + +var _ ProtectionIntent = BaseProtectionIntentImpl{} + +type BaseProtectionIntentImpl struct { + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s BaseProtectionIntentImpl) ProtectionIntent() BaseProtectionIntentImpl { + return s +} + +var _ ProtectionIntent = RawProtectionIntentImpl{} + +// RawProtectionIntentImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionIntentImpl struct { + protectionIntent BaseProtectionIntentImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionIntentImpl) ProtectionIntent() BaseProtectionIntentImpl { + return s.protectionIntent +} + +func UnmarshalProtectionIntentImplementation(input []byte) (ProtectionIntent, 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 ProtectionIntent into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["protectionIntentItemType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "RecoveryServiceVaultItem") { + var out AzureRecoveryServiceVaultProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureResourceItem") { + var out AzureResourceProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureResourceProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadAutoProtectionIntent") { + var out AzureWorkloadAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadAutoProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainerAutoProtectionIntent") { + var out AzureWorkloadContainerAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLAutoProtectionIntent") { + var out AzureWorkloadSQLAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + return out, nil + } + + var parent BaseProtectionIntentImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionIntentImpl: %+v", err) + } + + return RawProtectionIntentImpl{ + protectionIntent: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_protectionintentresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_protectionintentresource.go new file mode 100644 index 00000000000..a88830d2741 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/model_protectionintentresource.go @@ -0,0 +1,57 @@ +package backupprotectionintent + +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 ProtectionIntentResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionIntent `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionIntentResource{} + +func (s *ProtectionIntentResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 ProtectionIntentResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalProtectionIntentImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionIntentResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/predicates.go new file mode 100644 index 00000000000..26161b72fe6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/predicates.go @@ -0,0 +1,37 @@ +package backupprotectionintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionIntentResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionIntentResourceOperationPredicate) Matches(input ProtectionIntentResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/version.go new file mode 100644 index 00000000000..4d10f5c21d7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent/version.go @@ -0,0 +1,10 @@ +package backupprotectionintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupprotectionintent/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/README.md new file mode 100644 index 00000000000..639684053fd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/README.md @@ -0,0 +1,57 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs` Documentation + +The `backupresourceencryptionconfigs` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupresourceencryptionconfigs" +``` + + +### Client Initialization + +```go +client := backupresourceencryptionconfigs.NewBackupResourceEncryptionConfigsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupResourceEncryptionConfigsClient.Get` + +```go +ctx := context.TODO() +id := backupresourceencryptionconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +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: `BackupResourceEncryptionConfigsClient.Update` + +```go +ctx := context.TODO() +id := backupresourceencryptionconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := backupresourceencryptionconfigs.BackupResourceEncryptionConfigResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/client.go new file mode 100644 index 00000000000..5b406d30285 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/client.go @@ -0,0 +1,18 @@ +package backupresourceencryptionconfigs + +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 BackupResourceEncryptionConfigsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupResourceEncryptionConfigsClientWithBaseURI(endpoint string) BackupResourceEncryptionConfigsClient { + return BackupResourceEncryptionConfigsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/constants.go new file mode 100644 index 00000000000..29c88017b74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/constants.go @@ -0,0 +1,116 @@ +package backupresourceencryptionconfigs + +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 EncryptionAtRestType string + +const ( + EncryptionAtRestTypeCustomerManaged EncryptionAtRestType = "CustomerManaged" + EncryptionAtRestTypeInvalid EncryptionAtRestType = "Invalid" + EncryptionAtRestTypeMicrosoftManaged EncryptionAtRestType = "MicrosoftManaged" +) + +func PossibleValuesForEncryptionAtRestType() []string { + return []string{ + string(EncryptionAtRestTypeCustomerManaged), + string(EncryptionAtRestTypeInvalid), + string(EncryptionAtRestTypeMicrosoftManaged), + } +} + +func parseEncryptionAtRestType(input string) (*EncryptionAtRestType, error) { + vals := map[string]EncryptionAtRestType{ + "customermanaged": EncryptionAtRestTypeCustomerManaged, + "invalid": EncryptionAtRestTypeInvalid, + "microsoftmanaged": EncryptionAtRestTypeMicrosoftManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionAtRestType(input) + return &out, nil +} + +type InfrastructureEncryptionState string + +const ( + InfrastructureEncryptionStateDisabled InfrastructureEncryptionState = "Disabled" + InfrastructureEncryptionStateEnabled InfrastructureEncryptionState = "Enabled" + InfrastructureEncryptionStateInvalid InfrastructureEncryptionState = "Invalid" +) + +func PossibleValuesForInfrastructureEncryptionState() []string { + return []string{ + string(InfrastructureEncryptionStateDisabled), + string(InfrastructureEncryptionStateEnabled), + string(InfrastructureEncryptionStateInvalid), + } +} + +func parseInfrastructureEncryptionState(input string) (*InfrastructureEncryptionState, error) { + vals := map[string]InfrastructureEncryptionState{ + "disabled": InfrastructureEncryptionStateDisabled, + "enabled": InfrastructureEncryptionStateEnabled, + "invalid": InfrastructureEncryptionStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InfrastructureEncryptionState(input) + return &out, nil +} + +type LastUpdateStatus string + +const ( + LastUpdateStatusFailed LastUpdateStatus = "Failed" + LastUpdateStatusFirstInitialization LastUpdateStatus = "FirstInitialization" + LastUpdateStatusInitialized LastUpdateStatus = "Initialized" + LastUpdateStatusInvalid LastUpdateStatus = "Invalid" + LastUpdateStatusNotEnabled LastUpdateStatus = "NotEnabled" + LastUpdateStatusPartiallyFailed LastUpdateStatus = "PartiallyFailed" + LastUpdateStatusPartiallySucceeded LastUpdateStatus = "PartiallySucceeded" + LastUpdateStatusSucceeded LastUpdateStatus = "Succeeded" +) + +func PossibleValuesForLastUpdateStatus() []string { + return []string{ + string(LastUpdateStatusFailed), + string(LastUpdateStatusFirstInitialization), + string(LastUpdateStatusInitialized), + string(LastUpdateStatusInvalid), + string(LastUpdateStatusNotEnabled), + string(LastUpdateStatusPartiallyFailed), + string(LastUpdateStatusPartiallySucceeded), + string(LastUpdateStatusSucceeded), + } +} + +func parseLastUpdateStatus(input string) (*LastUpdateStatus, error) { + vals := map[string]LastUpdateStatus{ + "failed": LastUpdateStatusFailed, + "firstinitialization": LastUpdateStatusFirstInitialization, + "initialized": LastUpdateStatusInitialized, + "invalid": LastUpdateStatusInvalid, + "notenabled": LastUpdateStatusNotEnabled, + "partiallyfailed": LastUpdateStatusPartiallyFailed, + "partiallysucceeded": LastUpdateStatusPartiallySucceeded, + "succeeded": LastUpdateStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LastUpdateStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/id_vault.go new file mode 100644 index 00000000000..14fb6ab3840 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/id_vault.go @@ -0,0 +1,130 @@ +package backupresourceencryptionconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/id_vault_test.go new file mode 100644 index 00000000000..26d4bf4c9c2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/id_vault_test.go @@ -0,0 +1,282 @@ +package backupresourceencryptionconfigs + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/method_get_autorest.go new file mode 100644 index 00000000000..8946fde875a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/method_get_autorest.go @@ -0,0 +1,69 @@ +package backupresourceencryptionconfigs + +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 GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceEncryptionConfigExtendedResource +} + +// Get ... +func (c BackupResourceEncryptionConfigsClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupResourceEncryptionConfigsClient) preparerForGet(ctx context.Context, id VaultId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupEncryptionConfigs/backupResourceEncryptionConfig", 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 BackupResourceEncryptionConfigsClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/method_update_autorest.go new file mode 100644 index 00000000000..8e72a546ee0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/method_update_autorest.go @@ -0,0 +1,68 @@ +package backupresourceencryptionconfigs + +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 UpdateOperationResponse struct { + HttpResponse *http.Response +} + +// Update ... +func (c BackupResourceEncryptionConfigsClient) Update(ctx context.Context, id VaultId, input BackupResourceEncryptionConfigResource) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c BackupResourceEncryptionConfigsClient) preparerForUpdate(ctx context.Context, id VaultId, input BackupResourceEncryptionConfigResource) (*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(fmt.Sprintf("%s/backupEncryptionConfigs/backupResourceEncryptionConfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c BackupResourceEncryptionConfigsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go new file mode 100644 index 00000000000..04c2d9832cb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go @@ -0,0 +1,12 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfig struct { + EncryptionAtRestType *EncryptionAtRestType `json:"encryptionAtRestType,omitempty"` + InfrastructureEncryptionState *InfrastructureEncryptionState `json:"infrastructureEncryptionState,omitempty"` + KeyUri *string `json:"keyUri,omitempty"` + LastUpdateStatus *LastUpdateStatus `json:"lastUpdateStatus,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go new file mode 100644 index 00000000000..c58a1406581 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go @@ -0,0 +1,14 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfigExtended struct { + EncryptionAtRestType *EncryptionAtRestType `json:"encryptionAtRestType,omitempty"` + InfrastructureEncryptionState *InfrastructureEncryptionState `json:"infrastructureEncryptionState,omitempty"` + KeyUri *string `json:"keyUri,omitempty"` + LastUpdateStatus *LastUpdateStatus `json:"lastUpdateStatus,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + UseSystemAssignedIdentity *bool `json:"useSystemAssignedIdentity,omitempty"` + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go new file mode 100644 index 00000000000..748ecae7a86 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go @@ -0,0 +1,14 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfigExtendedResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupResourceEncryptionConfigExtended `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go new file mode 100644 index 00000000000..2bdfb74ffb3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go @@ -0,0 +1,14 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfigResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupResourceEncryptionConfig `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/version.go new file mode 100644 index 00000000000..38a3d3dc5a6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs/version.go @@ -0,0 +1,10 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupresourceencryptionconfigs/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/README.md new file mode 100644 index 00000000000..6026ac54873 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/README.md @@ -0,0 +1,78 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr` Documentation + +The `backupresourcestorageconfigsnoncrr` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupresourcestorageconfigsnoncrr" +``` + + +### Client Initialization + +```go +client := backupresourcestorageconfigsnoncrr.NewBackupResourceStorageConfigsNonCRRClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupResourceStorageConfigsNonCRRClient.Get` + +```go +ctx := context.TODO() +id := backupresourcestorageconfigsnoncrr.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +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: `BackupResourceStorageConfigsNonCRRClient.Patch` + +```go +ctx := context.TODO() +id := backupresourcestorageconfigsnoncrr.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := backupresourcestorageconfigsnoncrr.BackupResourceConfigResource{ + // ... +} + + +read, err := client.Patch(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupResourceStorageConfigsNonCRRClient.Update` + +```go +ctx := context.TODO() +id := backupresourcestorageconfigsnoncrr.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := backupresourcestorageconfigsnoncrr.BackupResourceConfigResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/client.go new file mode 100644 index 00000000000..88d28c49c49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/client.go @@ -0,0 +1,18 @@ +package backupresourcestorageconfigsnoncrr + +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 BackupResourceStorageConfigsNonCRRClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupResourceStorageConfigsNonCRRClientWithBaseURI(endpoint string) BackupResourceStorageConfigsNonCRRClient { + return BackupResourceStorageConfigsNonCRRClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/constants.go new file mode 100644 index 00000000000..401d538cf3b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/constants.go @@ -0,0 +1,138 @@ +package backupresourcestorageconfigsnoncrr + +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 DedupState string + +const ( + DedupStateDisabled DedupState = "Disabled" + DedupStateEnabled DedupState = "Enabled" + DedupStateInvalid DedupState = "Invalid" +) + +func PossibleValuesForDedupState() []string { + return []string{ + string(DedupStateDisabled), + string(DedupStateEnabled), + string(DedupStateInvalid), + } +} + +func parseDedupState(input string) (*DedupState, error) { + vals := map[string]DedupState{ + "disabled": DedupStateDisabled, + "enabled": DedupStateEnabled, + "invalid": DedupStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DedupState(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeGeoRedundant StorageType = "GeoRedundant" + StorageTypeInvalid StorageType = "Invalid" + StorageTypeLocallyRedundant StorageType = "LocallyRedundant" + StorageTypeReadAccessGeoZoneRedundant StorageType = "ReadAccessGeoZoneRedundant" + StorageTypeZoneRedundant StorageType = "ZoneRedundant" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeGeoRedundant), + string(StorageTypeInvalid), + string(StorageTypeLocallyRedundant), + string(StorageTypeReadAccessGeoZoneRedundant), + string(StorageTypeZoneRedundant), + } +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "georedundant": StorageTypeGeoRedundant, + "invalid": StorageTypeInvalid, + "locallyredundant": StorageTypeLocallyRedundant, + "readaccessgeozoneredundant": StorageTypeReadAccessGeoZoneRedundant, + "zoneredundant": StorageTypeZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type StorageTypeState string + +const ( + StorageTypeStateInvalid StorageTypeState = "Invalid" + StorageTypeStateLocked StorageTypeState = "Locked" + StorageTypeStateUnlocked StorageTypeState = "Unlocked" +) + +func PossibleValuesForStorageTypeState() []string { + return []string{ + string(StorageTypeStateInvalid), + string(StorageTypeStateLocked), + string(StorageTypeStateUnlocked), + } +} + +func parseStorageTypeState(input string) (*StorageTypeState, error) { + vals := map[string]StorageTypeState{ + "invalid": StorageTypeStateInvalid, + "locked": StorageTypeStateLocked, + "unlocked": StorageTypeStateUnlocked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageTypeState(input) + return &out, nil +} + +type XcoolState string + +const ( + XcoolStateDisabled XcoolState = "Disabled" + XcoolStateEnabled XcoolState = "Enabled" + XcoolStateInvalid XcoolState = "Invalid" +) + +func PossibleValuesForXcoolState() []string { + return []string{ + string(XcoolStateDisabled), + string(XcoolStateEnabled), + string(XcoolStateInvalid), + } +} + +func parseXcoolState(input string) (*XcoolState, error) { + vals := map[string]XcoolState{ + "disabled": XcoolStateDisabled, + "enabled": XcoolStateEnabled, + "invalid": XcoolStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := XcoolState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/id_vault.go new file mode 100644 index 00000000000..c0d1d5f13ca --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/id_vault.go @@ -0,0 +1,130 @@ +package backupresourcestorageconfigsnoncrr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/id_vault_test.go new file mode 100644 index 00000000000..dcd281c7a3b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/id_vault_test.go @@ -0,0 +1,282 @@ +package backupresourcestorageconfigsnoncrr + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go new file mode 100644 index 00000000000..dfa7631d81e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go @@ -0,0 +1,69 @@ +package backupresourcestorageconfigsnoncrr + +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 GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceConfigResource +} + +// Get ... +func (c BackupResourceStorageConfigsNonCRRClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupResourceStorageConfigsNonCRRClient) preparerForGet(ctx context.Context, id VaultId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig", 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 BackupResourceStorageConfigsNonCRRClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go new file mode 100644 index 00000000000..06e35a3cb44 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go @@ -0,0 +1,68 @@ +package backupresourcestorageconfigsnoncrr + +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 PatchOperationResponse struct { + HttpResponse *http.Response +} + +// Patch ... +func (c BackupResourceStorageConfigsNonCRRClient) Patch(ctx context.Context, id VaultId, input BackupResourceConfigResource) (result PatchOperationResponse, err error) { + req, err := c.preparerForPatch(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Patch", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Patch", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPatch(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Patch", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForPatch prepares the Patch request. +func (c BackupResourceStorageConfigsNonCRRClient) preparerForPatch(ctx context.Context, id VaultId, input BackupResourceConfigResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPatch handles the response to the Patch request. The method always +// closes the http.Response Body. +func (c BackupResourceStorageConfigsNonCRRClient) responderForPatch(resp *http.Response) (result PatchOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go new file mode 100644 index 00000000000..13a010ee69d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go @@ -0,0 +1,70 @@ +package backupresourcestorageconfigsnoncrr + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceConfigResource +} + +// Update ... +func (c BackupResourceStorageConfigsNonCRRClient) Update(ctx context.Context, id VaultId, input BackupResourceConfigResource) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c BackupResourceStorageConfigsNonCRRClient) preparerForUpdate(ctx context.Context, id VaultId, input BackupResourceConfigResource) (*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(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c BackupResourceStorageConfigsNonCRRClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go new file mode 100644 index 00000000000..69f226c0dcf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go @@ -0,0 +1,13 @@ +package backupresourcestorageconfigsnoncrr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceConfig struct { + CrossRegionRestoreFlag *bool `json:"crossRegionRestoreFlag,omitempty"` + DedupState *DedupState `json:"dedupState,omitempty"` + StorageModelType *StorageType `json:"storageModelType,omitempty"` + StorageType *StorageType `json:"storageType,omitempty"` + StorageTypeState *StorageTypeState `json:"storageTypeState,omitempty"` + XcoolState *XcoolState `json:"xcoolState,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go new file mode 100644 index 00000000000..8fc2680cafb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go @@ -0,0 +1,14 @@ +package backupresourcestorageconfigsnoncrr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceConfigResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupResourceConfig `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/version.go new file mode 100644 index 00000000000..f6123c82c83 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr/version.go @@ -0,0 +1,10 @@ +package backupresourcestorageconfigsnoncrr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupresourcestorageconfigsnoncrr/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/README.md new file mode 100644 index 00000000000..163fc8c5d36 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/README.md @@ -0,0 +1,78 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs` Documentation + +The `backupresourcevaultconfigs` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupresourcevaultconfigs" +``` + + +### Client Initialization + +```go +client := backupresourcevaultconfigs.NewBackupResourceVaultConfigsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupResourceVaultConfigsClient.Get` + +```go +ctx := context.TODO() +id := backupresourcevaultconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +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: `BackupResourceVaultConfigsClient.Put` + +```go +ctx := context.TODO() +id := backupresourcevaultconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := backupresourcevaultconfigs.BackupResourceVaultConfigResource{ + // ... +} + + +read, err := client.Put(ctx, id, payload, backupresourcevaultconfigs.DefaultPutOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupResourceVaultConfigsClient.Update` + +```go +ctx := context.TODO() +id := backupresourcevaultconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := backupresourcevaultconfigs.BackupResourceVaultConfigResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload, backupresourcevaultconfigs.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/client.go new file mode 100644 index 00000000000..b56d05bcc6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/client.go @@ -0,0 +1,18 @@ +package backupresourcevaultconfigs + +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 BackupResourceVaultConfigsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupResourceVaultConfigsClientWithBaseURI(endpoint string) BackupResourceVaultConfigsClient { + return BackupResourceVaultConfigsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/constants.go new file mode 100644 index 00000000000..b3cc9f2074c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/constants.go @@ -0,0 +1,141 @@ +package backupresourcevaultconfigs + +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 EnhancedSecurityState string + +const ( + EnhancedSecurityStateDisabled EnhancedSecurityState = "Disabled" + EnhancedSecurityStateEnabled EnhancedSecurityState = "Enabled" + EnhancedSecurityStateInvalid EnhancedSecurityState = "Invalid" +) + +func PossibleValuesForEnhancedSecurityState() []string { + return []string{ + string(EnhancedSecurityStateDisabled), + string(EnhancedSecurityStateEnabled), + string(EnhancedSecurityStateInvalid), + } +} + +func parseEnhancedSecurityState(input string) (*EnhancedSecurityState, error) { + vals := map[string]EnhancedSecurityState{ + "disabled": EnhancedSecurityStateDisabled, + "enabled": EnhancedSecurityStateEnabled, + "invalid": EnhancedSecurityStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnhancedSecurityState(input) + return &out, nil +} + +type SoftDeleteFeatureState string + +const ( + SoftDeleteFeatureStateAlwaysON SoftDeleteFeatureState = "AlwaysON" + SoftDeleteFeatureStateDisabled SoftDeleteFeatureState = "Disabled" + SoftDeleteFeatureStateEnabled SoftDeleteFeatureState = "Enabled" + SoftDeleteFeatureStateInvalid SoftDeleteFeatureState = "Invalid" +) + +func PossibleValuesForSoftDeleteFeatureState() []string { + return []string{ + string(SoftDeleteFeatureStateAlwaysON), + string(SoftDeleteFeatureStateDisabled), + string(SoftDeleteFeatureStateEnabled), + string(SoftDeleteFeatureStateInvalid), + } +} + +func parseSoftDeleteFeatureState(input string) (*SoftDeleteFeatureState, error) { + vals := map[string]SoftDeleteFeatureState{ + "alwayson": SoftDeleteFeatureStateAlwaysON, + "disabled": SoftDeleteFeatureStateDisabled, + "enabled": SoftDeleteFeatureStateEnabled, + "invalid": SoftDeleteFeatureStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SoftDeleteFeatureState(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeGeoRedundant StorageType = "GeoRedundant" + StorageTypeInvalid StorageType = "Invalid" + StorageTypeLocallyRedundant StorageType = "LocallyRedundant" + StorageTypeReadAccessGeoZoneRedundant StorageType = "ReadAccessGeoZoneRedundant" + StorageTypeZoneRedundant StorageType = "ZoneRedundant" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeGeoRedundant), + string(StorageTypeInvalid), + string(StorageTypeLocallyRedundant), + string(StorageTypeReadAccessGeoZoneRedundant), + string(StorageTypeZoneRedundant), + } +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "georedundant": StorageTypeGeoRedundant, + "invalid": StorageTypeInvalid, + "locallyredundant": StorageTypeLocallyRedundant, + "readaccessgeozoneredundant": StorageTypeReadAccessGeoZoneRedundant, + "zoneredundant": StorageTypeZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type StorageTypeState string + +const ( + StorageTypeStateInvalid StorageTypeState = "Invalid" + StorageTypeStateLocked StorageTypeState = "Locked" + StorageTypeStateUnlocked StorageTypeState = "Unlocked" +) + +func PossibleValuesForStorageTypeState() []string { + return []string{ + string(StorageTypeStateInvalid), + string(StorageTypeStateLocked), + string(StorageTypeStateUnlocked), + } +} + +func parseStorageTypeState(input string) (*StorageTypeState, error) { + vals := map[string]StorageTypeState{ + "invalid": StorageTypeStateInvalid, + "locked": StorageTypeStateLocked, + "unlocked": StorageTypeStateUnlocked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageTypeState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/id_vault.go new file mode 100644 index 00000000000..9413d3f826a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/id_vault.go @@ -0,0 +1,130 @@ +package backupresourcevaultconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/id_vault_test.go new file mode 100644 index 00000000000..1c6da221d84 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/id_vault_test.go @@ -0,0 +1,282 @@ +package backupresourcevaultconfigs + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_get_autorest.go new file mode 100644 index 00000000000..709a6190da7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_get_autorest.go @@ -0,0 +1,69 @@ +package backupresourcevaultconfigs + +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 GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceVaultConfigResource +} + +// Get ... +func (c BackupResourceVaultConfigsClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupResourceVaultConfigsClient) preparerForGet(ctx context.Context, id VaultId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupconfig/vaultconfig", 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 BackupResourceVaultConfigsClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_put_autorest.go new file mode 100644 index 00000000000..553319e53dc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_put_autorest.go @@ -0,0 +1,99 @@ +package backupresourcevaultconfigs + +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 PutOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceVaultConfigResource +} + +type PutOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultPutOperationOptions() PutOperationOptions { + return PutOperationOptions{} +} + +func (o PutOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o PutOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Put ... +func (c BackupResourceVaultConfigsClient) Put(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource, options PutOperationOptions) (result PutOperationResponse, err error) { + req, err := c.preparerForPut(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Put", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Put", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPut(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Put", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForPut prepares the Put request. +func (c BackupResourceVaultConfigsClient) preparerForPut(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource, options PutOperationOptions) (*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.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupconfig/vaultconfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPut handles the response to the Put request. The method always +// closes the http.Response Body. +func (c BackupResourceVaultConfigsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_update_autorest.go new file mode 100644 index 00000000000..6bc2ec4acdf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/method_update_autorest.go @@ -0,0 +1,99 @@ +package backupresourcevaultconfigs + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceVaultConfigResource +} + +type UpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o UpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Update ... +func (c BackupResourceVaultConfigsClient) Update(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c BackupResourceVaultConfigsClient) preparerForUpdate(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource, options UpdateOperationOptions) (*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.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupconfig/vaultconfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c BackupResourceVaultConfigsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go new file mode 100644 index 00000000000..43c59de4141 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go @@ -0,0 +1,15 @@ +package backupresourcevaultconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceVaultConfig struct { + EnhancedSecurityState *EnhancedSecurityState `json:"enhancedSecurityState,omitempty"` + IsSoftDeleteFeatureStateEditable *bool `json:"isSoftDeleteFeatureStateEditable,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteFeatureState *SoftDeleteFeatureState `json:"softDeleteFeatureState,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + StorageModelType *StorageType `json:"storageModelType,omitempty"` + StorageType *StorageType `json:"storageType,omitempty"` + StorageTypeState *StorageTypeState `json:"storageTypeState,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go new file mode 100644 index 00000000000..9957131bbd6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go @@ -0,0 +1,14 @@ +package backupresourcevaultconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceVaultConfigResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupResourceVaultConfig `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/version.go new file mode 100644 index 00000000000..27cc68c05df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs/version.go @@ -0,0 +1,10 @@ +package backupresourcevaultconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupresourcevaultconfigs/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backups/README.md new file mode 100644 index 00000000000..5f485148eab --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backups` Documentation + +The `backups` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backups" +``` + + +### Client Initialization + +```go +client := backups.NewBackupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupsClient.Trigger` + +```go +ctx := context.TODO() +id := backups.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + +payload := backups.BackupRequestResource{ + // ... +} + + +read, err := client.Trigger(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/client.go new file mode 100644 index 00000000000..8669bac74ee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/client.go @@ -0,0 +1,18 @@ +package backups + +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 BackupsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupsClientWithBaseURI(endpoint string) BackupsClient { + return BackupsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/constants.go new file mode 100644 index 00000000000..0e9ea57090f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/constants.go @@ -0,0 +1,54 @@ +package backups + +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 BackupType string + +const ( + BackupTypeCopyOnlyFull BackupType = "CopyOnlyFull" + BackupTypeDifferential BackupType = "Differential" + BackupTypeFull BackupType = "Full" + BackupTypeIncremental BackupType = "Incremental" + BackupTypeInvalid BackupType = "Invalid" + BackupTypeLog BackupType = "Log" + BackupTypeSnapshotCopyOnlyFull BackupType = "SnapshotCopyOnlyFull" + BackupTypeSnapshotFull BackupType = "SnapshotFull" +) + +func PossibleValuesForBackupType() []string { + return []string{ + string(BackupTypeCopyOnlyFull), + string(BackupTypeDifferential), + string(BackupTypeFull), + string(BackupTypeIncremental), + string(BackupTypeInvalid), + string(BackupTypeLog), + string(BackupTypeSnapshotCopyOnlyFull), + string(BackupTypeSnapshotFull), + } +} + +func parseBackupType(input string) (*BackupType, error) { + vals := map[string]BackupType{ + "copyonlyfull": BackupTypeCopyOnlyFull, + "differential": BackupTypeDifferential, + "full": BackupTypeFull, + "incremental": BackupTypeIncremental, + "invalid": BackupTypeInvalid, + "log": BackupTypeLog, + "snapshotcopyonlyfull": BackupTypeSnapshotCopyOnlyFull, + "snapshotfull": BackupTypeSnapshotFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/id_protecteditem.go new file mode 100644 index 00000000000..d87af28e375 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/id_protecteditem.go @@ -0,0 +1,157 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProtectedItemId{}) +} + +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) + } + + id := ProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := ProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backups/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/id_protecteditem_test.go new file mode 100644 index 00000000000..bd7b39d1112 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/id_protecteditem_test.go @@ -0,0 +1,417 @@ +package backups + +import ( + "testing" + + "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{} + +func TestNewProtectedItemID(t *testing.T) { + id := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } + + if id.ProtectedItemName != "protectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemName") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestParseProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + ProtectedItemName: "pRoTeCtEdItEmNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestSegmentsForProtectedItemId(t *testing.T) { + segments := ProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/method_trigger_autorest.go new file mode 100644 index 00000000000..bf23ac4685b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/method_trigger_autorest.go @@ -0,0 +1,68 @@ +package backups + +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 TriggerOperationResponse struct { + HttpResponse *http.Response +} + +// Trigger ... +func (c BackupsClient) Trigger(ctx context.Context, id ProtectedItemId, input BackupRequestResource) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Trigger", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Trigger", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTrigger(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Trigger", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTrigger prepares the Trigger request. +func (c BackupsClient) preparerForTrigger(ctx context.Context, id ProtectedItemId, input BackupRequestResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backup", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTrigger handles the response to the Trigger request. The method always +// closes the http.Response Body. +func (c BackupsClient) responderForTrigger(resp *http.Response) (result TriggerOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_azurefilesharebackuprequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_azurefilesharebackuprequest.go new file mode 100644 index 00000000000..ff4e3c89e51 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_azurefilesharebackuprequest.go @@ -0,0 +1,50 @@ +package backups + +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 _ BackupRequest = AzureFileShareBackupRequest{} + +type AzureFileShareBackupRequest struct { + RecoveryPointExpiryTimeInUTC *string `json:"recoveryPointExpiryTimeInUTC,omitempty"` + + // Fields inherited from BackupRequest + + ObjectType string `json:"objectType"` +} + +func (s AzureFileShareBackupRequest) BackupRequest() BaseBackupRequestImpl { + return BaseBackupRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureFileShareBackupRequest{} + +func (s AzureFileShareBackupRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareBackupRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareBackupRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareBackupRequest: %+v", err) + } + + decoded["objectType"] = "AzureFileShareBackupRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareBackupRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_azureworkloadbackuprequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_azureworkloadbackuprequest.go new file mode 100644 index 00000000000..4571f1135be --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_azureworkloadbackuprequest.go @@ -0,0 +1,52 @@ +package backups + +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 _ BackupRequest = AzureWorkloadBackupRequest{} + +type AzureWorkloadBackupRequest struct { + BackupType *BackupType `json:"backupType,omitempty"` + EnableCompression *bool `json:"enableCompression,omitempty"` + RecoveryPointExpiryTimeInUTC *string `json:"recoveryPointExpiryTimeInUTC,omitempty"` + + // Fields inherited from BackupRequest + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadBackupRequest) BackupRequest() BaseBackupRequestImpl { + return BaseBackupRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadBackupRequest{} + +func (s AzureWorkloadBackupRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadBackupRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadBackupRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadBackupRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadBackupRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadBackupRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_backuprequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_backuprequest.go new file mode 100644 index 00000000000..19e8d888c90 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_backuprequest.go @@ -0,0 +1,91 @@ +package backups + +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 BackupRequest interface { + BackupRequest() BaseBackupRequestImpl +} + +var _ BackupRequest = BaseBackupRequestImpl{} + +type BaseBackupRequestImpl struct { + ObjectType string `json:"objectType"` +} + +func (s BaseBackupRequestImpl) BackupRequest() BaseBackupRequestImpl { + return s +} + +var _ BackupRequest = RawBackupRequestImpl{} + +// RawBackupRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawBackupRequestImpl struct { + backupRequest BaseBackupRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawBackupRequestImpl) BackupRequest() BaseBackupRequestImpl { + return s.backupRequest +} + +func UnmarshalBackupRequestImplementation(input []byte) (BackupRequest, 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 BackupRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureFileShareBackupRequest") { + var out AzureFileShareBackupRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareBackupRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadBackupRequest") { + var out AzureWorkloadBackupRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadBackupRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMBackupRequest") { + var out IaasVMBackupRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMBackupRequest: %+v", err) + } + return out, nil + } + + var parent BaseBackupRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseBackupRequestImpl: %+v", err) + } + + return RawBackupRequestImpl{ + backupRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_backuprequestresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_backuprequestresource.go new file mode 100644 index 00000000000..14cfe2f2003 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_backuprequestresource.go @@ -0,0 +1,57 @@ +package backups + +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 BackupRequestResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties BackupRequest `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &BackupRequestResource{} + +func (s *BackupRequestResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 BackupRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalBackupRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'BackupRequestResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_iaasvmbackuprequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_iaasvmbackuprequest.go new file mode 100644 index 00000000000..bffc37ffa9c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/model_iaasvmbackuprequest.go @@ -0,0 +1,50 @@ +package backups + +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 _ BackupRequest = IaasVMBackupRequest{} + +type IaasVMBackupRequest struct { + RecoveryPointExpiryTimeInUTC *string `json:"recoveryPointExpiryTimeInUTC,omitempty"` + + // Fields inherited from BackupRequest + + ObjectType string `json:"objectType"` +} + +func (s IaasVMBackupRequest) BackupRequest() BaseBackupRequestImpl { + return BaseBackupRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = IaasVMBackupRequest{} + +func (s IaasVMBackupRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMBackupRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMBackupRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMBackupRequest: %+v", err) + } + + decoded["objectType"] = "IaasVMBackupRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMBackupRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backups/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backups/version.go new file mode 100644 index 00000000000..de093e7a763 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backups/version.go @@ -0,0 +1,10 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backups/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/README.md new file mode 100644 index 00000000000..b501fd4e7dd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus` Documentation + +The `backupstatus` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupstatus" +``` + + +### Client Initialization + +```go +client := backupstatus.NewBackupStatusClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupStatusClient.Get` + +```go +ctx := context.TODO() +id := backupstatus.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := backupstatus.BackupStatusRequest{ + // ... +} + + +read, err := client.Get(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/client.go new file mode 100644 index 00000000000..d17f64f2d24 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/client.go @@ -0,0 +1,18 @@ +package backupstatus + +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 BackupStatusClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupStatusClientWithBaseURI(endpoint string) BackupStatusClient { + return BackupStatusClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/constants.go new file mode 100644 index 00000000000..2ee8d184452 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/constants.go @@ -0,0 +1,171 @@ +package backupstatus + +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 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" + DataSourceTypeSAPHanaDBInstance DataSourceType = "SAPHanaDBInstance" + 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(DataSourceTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": DataSourceTypeSAPHanaDBInstance, + "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 FabricName string + +const ( + FabricNameAzure FabricName = "Azure" + FabricNameInvalid FabricName = "Invalid" +) + +func PossibleValuesForFabricName() []string { + return []string{ + string(FabricNameAzure), + string(FabricNameInvalid), + } +} + +func parseFabricName(input string) (*FabricName, error) { + vals := map[string]FabricName{ + "azure": FabricNameAzure, + "invalid": FabricNameInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FabricName(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/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/id_location.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/id_location.go new file mode 100644 index 00000000000..417d5cf70d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/id_location.go @@ -0,0 +1,121 @@ +package backupstatus + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/id_location_test.go new file mode 100644 index 00000000000..e5365b1bacb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/id_location_test.go @@ -0,0 +1,237 @@ +package backupstatus + +import ( + "testing" + + "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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/method_get_autorest.go new file mode 100644 index 00000000000..5bdbd049ea0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/method_get_autorest.go @@ -0,0 +1,70 @@ +package backupstatus + +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 GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupStatusResponse +} + +// Get ... +func (c BackupStatusClient) Get(ctx context.Context, id LocationId, input BackupStatusRequest) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backupstatus.BackupStatusClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupstatus.BackupStatusClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupstatus.BackupStatusClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupStatusClient) preparerForGet(ctx context.Context, id LocationId, input BackupStatusRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStatus", id.ID())), + autorest.WithJSON(input), + 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 BackupStatusClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/model_backupstatusrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/model_backupstatusrequest.go new file mode 100644 index 00000000000..18355d1d1a4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/model_backupstatusrequest.go @@ -0,0 +1,10 @@ +package backupstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupStatusRequest struct { + PoLogicalName *string `json:"poLogicalName,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceType *DataSourceType `json:"resourceType,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/model_backupstatusresponse.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/model_backupstatusresponse.go new file mode 100644 index 00000000000..18836147a5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/model_backupstatusresponse.go @@ -0,0 +1,18 @@ +package backupstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupStatusResponse struct { + AcquireStorageAccountLock *AcquireStorageAccountLock `json:"acquireStorageAccountLock,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + FabricName *FabricName `json:"fabricName,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ProtectionStatus *ProtectionStatus `json:"protectionStatus,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` + VaultId *string `json:"vaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/version.go new file mode 100644 index 00000000000..6b487f2aab6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus/version.go @@ -0,0 +1,10 @@ +package backupstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupstatus/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/README.md new file mode 100644 index 00000000000..f208775c308 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries` Documentation + +The `backupusagesummaries` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupusagesummaries" +``` + + +### Client Initialization + +```go +client := backupusagesummaries.NewBackupUsageSummariesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupUsageSummariesClient.List` + +```go +ctx := context.TODO() +id := backupusagesummaries.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +read, err := client.List(ctx, id, backupusagesummaries.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/client.go new file mode 100644 index 00000000000..d6dbffa806e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/client.go @@ -0,0 +1,18 @@ +package backupusagesummaries + +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 BackupUsageSummariesClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupUsageSummariesClientWithBaseURI(endpoint string) BackupUsageSummariesClient { + return BackupUsageSummariesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/constants.go new file mode 100644 index 00000000000..35bb7f168aa --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/constants.go @@ -0,0 +1,48 @@ +package backupusagesummaries + +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 UsagesUnit string + +const ( + UsagesUnitBytes UsagesUnit = "Bytes" + UsagesUnitBytesPerSecond UsagesUnit = "BytesPerSecond" + UsagesUnitCount UsagesUnit = "Count" + UsagesUnitCountPerSecond UsagesUnit = "CountPerSecond" + UsagesUnitPercent UsagesUnit = "Percent" + UsagesUnitSeconds UsagesUnit = "Seconds" +) + +func PossibleValuesForUsagesUnit() []string { + return []string{ + string(UsagesUnitBytes), + string(UsagesUnitBytesPerSecond), + string(UsagesUnitCount), + string(UsagesUnitCountPerSecond), + string(UsagesUnitPercent), + string(UsagesUnitSeconds), + } +} + +func parseUsagesUnit(input string) (*UsagesUnit, error) { + vals := map[string]UsagesUnit{ + "bytes": UsagesUnitBytes, + "bytespersecond": UsagesUnitBytesPerSecond, + "count": UsagesUnitCount, + "countpersecond": UsagesUnitCountPerSecond, + "percent": UsagesUnitPercent, + "seconds": UsagesUnitSeconds, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsagesUnit(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/id_vault.go new file mode 100644 index 00000000000..6c678e26ebe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/id_vault.go @@ -0,0 +1,130 @@ +package backupusagesummaries + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/id_vault_test.go new file mode 100644 index 00000000000..3531163a6df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/id_vault_test.go @@ -0,0 +1,282 @@ +package backupusagesummaries + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/method_list_autorest.go new file mode 100644 index 00000000000..f3562412897 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/method_list_autorest.go @@ -0,0 +1,98 @@ +package backupusagesummaries + +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 ListOperationResponse struct { + HttpResponse *http.Response + Model *BackupManagementUsageList +} + +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 BackupUsageSummariesClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupusagesummaries.BackupUsageSummariesClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupusagesummaries.BackupUsageSummariesClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupusagesummaries.BackupUsageSummariesClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForList prepares the List request. +func (c BackupUsageSummariesClient) 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/backupUsageSummaries", id.ID())), + 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 BackupUsageSummariesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_backupmanagementusage.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_backupmanagementusage.go new file mode 100644 index 00000000000..decb29b6951 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_backupmanagementusage.go @@ -0,0 +1,31 @@ +package backupusagesummaries + +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 BackupManagementUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *NameInfo `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + Unit *UsagesUnit `json:"unit,omitempty"` +} + +func (o *BackupManagementUsage) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupManagementUsage) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_backupmanagementusagelist.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_backupmanagementusagelist.go new file mode 100644 index 00000000000..e2014e84694 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_backupmanagementusagelist.go @@ -0,0 +1,8 @@ +package backupusagesummaries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementUsageList struct { + Value *[]BackupManagementUsage `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_nameinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_nameinfo.go new file mode 100644 index 00000000000..68fde56d864 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/model_nameinfo.go @@ -0,0 +1,9 @@ +package backupusagesummaries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameInfo struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/version.go new file mode 100644 index 00000000000..6e39a54b275 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries/version.go @@ -0,0 +1,10 @@ +package backupusagesummaries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupusagesummaries/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/README.md new file mode 100644 index 00000000000..273c9083c1d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems` Documentation + +The `backupworkloaditems` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/backupworkloaditems" +``` + + +### Client Initialization + +```go +client := backupworkloaditems.NewBackupWorkloadItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupWorkloadItemsClient.List` + +```go +ctx := context.TODO() +id := backupworkloaditems.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName") + +// alternatively `client.List(ctx, id, backupworkloaditems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupworkloaditems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/client.go new file mode 100644 index 00000000000..2493a9d3ce5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/client.go @@ -0,0 +1,18 @@ +package backupworkloaditems + +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 BackupWorkloadItemsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupWorkloadItemsClientWithBaseURI(endpoint string) BackupWorkloadItemsClient { + return BackupWorkloadItemsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/constants.go new file mode 100644 index 00000000000..04f820247b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/constants.go @@ -0,0 +1,76 @@ +package backupworkloaditems + +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 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 +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/id_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/id_protectioncontainer.go new file mode 100644 index 00000000000..f6bef435f47 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/id_protectioncontainer.go @@ -0,0 +1,148 @@ +package backupworkloaditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProtectionContainerId{}) +} + +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) + } + + id := ProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := ProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/id_protectioncontainer_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/id_protectioncontainer_test.go new file mode 100644 index 00000000000..f2b0acee461 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/id_protectioncontainer_test.go @@ -0,0 +1,372 @@ +package backupworkloaditems + +import ( + "testing" + + "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{} + +func TestNewProtectionContainerID(t *testing.T) { + id := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } +} + +func TestFormatProtectionContainerID(t *testing.T) { + actual := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + } +} + +func TestParseProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + } +} + +func TestSegmentsForProtectionContainerId(t *testing.T) { + segments := ProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/method_list_autorest.go new file mode 100644 index 00000000000..a730a74a266 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupworkloaditems + +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 *[]WorkloadItemResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []WorkloadItemResource +} + +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 BackupWorkloadItemsClient) List(ctx context.Context, id ProtectionContainerId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupWorkloadItemsClient) preparerForList(ctx context.Context, id ProtectionContainerId, 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/items", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupWorkloadItemsClient) 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 BackupWorkloadItemsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []WorkloadItemResource `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, "backupworkloaditems.BackupWorkloadItemsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupWorkloadItemsClient) ListComplete(ctx context.Context, id ProtectionContainerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkloadItemResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupWorkloadItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id ProtectionContainerId, options ListOperationOptions, predicate WorkloadItemResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]WorkloadItemResource, 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/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloaditem.go new file mode 100644 index 00000000000..1cfdf68c3de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloaditem.go @@ -0,0 +1,62 @@ +package backupworkloaditems + +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 _ WorkloadItem = AzureVMWorkloadItem{} + +type AzureVMWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadItemType string `json:"workloadItemType"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadItem) WorkloadItem() BaseWorkloadItemImpl { + return BaseWorkloadItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectionState: s.ProtectionState, + WorkloadItemType: s.WorkloadItemType, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadItem{} + +func (s AzureVMWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadItem: %+v", err) + } + + decoded["workloadItemType"] = "AzureVmWorkloadItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go new file mode 100644 index 00000000000..36fdacb1151 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go @@ -0,0 +1,62 @@ +package backupworkloaditems + +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 _ WorkloadItem = AzureVMWorkloadSAPAseDatabaseWorkloadItem{} + +type AzureVMWorkloadSAPAseDatabaseWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadItemType string `json:"workloadItemType"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPAseDatabaseWorkloadItem) WorkloadItem() BaseWorkloadItemImpl { + return BaseWorkloadItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectionState: s.ProtectionState, + WorkloadItemType: s.WorkloadItemType, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseDatabaseWorkloadItem{} + +func (s AzureVMWorkloadSAPAseDatabaseWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseDatabaseWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseDatabaseWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseDatabaseWorkloadItem: %+v", err) + } + + decoded["workloadItemType"] = "SAPAseDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseDatabaseWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go new file mode 100644 index 00000000000..3ac63f560d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go @@ -0,0 +1,62 @@ +package backupworkloaditems + +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 _ WorkloadItem = AzureVMWorkloadSAPAseSystemWorkloadItem{} + +type AzureVMWorkloadSAPAseSystemWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadItemType string `json:"workloadItemType"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPAseSystemWorkloadItem) WorkloadItem() BaseWorkloadItemImpl { + return BaseWorkloadItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectionState: s.ProtectionState, + WorkloadItemType: s.WorkloadItemType, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseSystemWorkloadItem{} + +func (s AzureVMWorkloadSAPAseSystemWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseSystemWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseSystemWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseSystemWorkloadItem: %+v", err) + } + + decoded["workloadItemType"] = "SAPAseSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseSystemWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go new file mode 100644 index 00000000000..470530a883c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go @@ -0,0 +1,62 @@ +package backupworkloaditems + +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 _ WorkloadItem = AzureVMWorkloadSAPHanaDatabaseWorkloadItem{} + +type AzureVMWorkloadSAPHanaDatabaseWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadItemType string `json:"workloadItemType"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaDatabaseWorkloadItem) WorkloadItem() BaseWorkloadItemImpl { + return BaseWorkloadItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectionState: s.ProtectionState, + WorkloadItemType: s.WorkloadItemType, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseWorkloadItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseWorkloadItem: %+v", err) + } + + decoded["workloadItemType"] = "SAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go new file mode 100644 index 00000000000..41d102cc6e5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go @@ -0,0 +1,62 @@ +package backupworkloaditems + +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 _ WorkloadItem = AzureVMWorkloadSAPHanaSystemWorkloadItem{} + +type AzureVMWorkloadSAPHanaSystemWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadItemType string `json:"workloadItemType"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaSystemWorkloadItem) WorkloadItem() BaseWorkloadItemImpl { + return BaseWorkloadItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectionState: s.ProtectionState, + WorkloadItemType: s.WorkloadItemType, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaSystemWorkloadItem{} + +func (s AzureVMWorkloadSAPHanaSystemWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaSystemWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaSystemWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaSystemWorkloadItem: %+v", err) + } + + decoded["workloadItemType"] = "SAPHanaSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaSystemWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go new file mode 100644 index 00000000000..21f279752ad --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go @@ -0,0 +1,62 @@ +package backupworkloaditems + +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 _ WorkloadItem = AzureVMWorkloadSQLDatabaseWorkloadItem{} + +type AzureVMWorkloadSQLDatabaseWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadItemType string `json:"workloadItemType"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSQLDatabaseWorkloadItem) WorkloadItem() BaseWorkloadItemImpl { + return BaseWorkloadItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectionState: s.ProtectionState, + WorkloadItemType: s.WorkloadItemType, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseWorkloadItem{} + +func (s AzureVMWorkloadSQLDatabaseWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseWorkloadItem: %+v", err) + } + + decoded["workloadItemType"] = "SQLDataBase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go new file mode 100644 index 00000000000..c03f001a557 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go @@ -0,0 +1,63 @@ +package backupworkloaditems + +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 _ WorkloadItem = AzureVMWorkloadSQLInstanceWorkloadItem{} + +type AzureVMWorkloadSQLInstanceWorkloadItem struct { + DataDirectoryPaths *[]SQLDataDirectory `json:"dataDirectoryPaths,omitempty"` + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadItemType string `json:"workloadItemType"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSQLInstanceWorkloadItem) WorkloadItem() BaseWorkloadItemImpl { + return BaseWorkloadItemImpl{ + BackupManagementType: s.BackupManagementType, + FriendlyName: s.FriendlyName, + ProtectionState: s.ProtectionState, + WorkloadItemType: s.WorkloadItemType, + WorkloadType: s.WorkloadType, + } +} + +var _ json.Marshaler = AzureVMWorkloadSQLInstanceWorkloadItem{} + +func (s AzureVMWorkloadSQLInstanceWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLInstanceWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLInstanceWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLInstanceWorkloadItem: %+v", err) + } + + decoded["workloadItemType"] = "SQLInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLInstanceWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_sqldatadirectory.go new file mode 100644 index 00000000000..2bae2b886be --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_sqldatadirectory.go @@ -0,0 +1,10 @@ +package backupworkloaditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectory struct { + LogicalName *string `json:"logicalName,omitempty"` + Path *string `json:"path,omitempty"` + Type *SQLDataDirectoryType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_workloaditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_workloaditem.go new file mode 100644 index 00000000000..b27107f34d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_workloaditem.go @@ -0,0 +1,127 @@ +package backupworkloaditems + +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 WorkloadItem interface { + WorkloadItem() BaseWorkloadItemImpl +} + +var _ WorkloadItem = BaseWorkloadItemImpl{} + +type BaseWorkloadItemImpl struct { + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadItemType string `json:"workloadItemType"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +func (s BaseWorkloadItemImpl) WorkloadItem() BaseWorkloadItemImpl { + return s +} + +var _ WorkloadItem = RawWorkloadItemImpl{} + +// RawWorkloadItemImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawWorkloadItemImpl struct { + workloadItem BaseWorkloadItemImpl + Type string + Values map[string]interface{} +} + +func (s RawWorkloadItemImpl) WorkloadItem() BaseWorkloadItemImpl { + return s.workloadItem +} + +func UnmarshalWorkloadItemImplementation(input []byte) (WorkloadItem, 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 WorkloadItem into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["workloadItemType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureVmWorkloadItem") { + var out AzureVMWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPAseDatabase") { + var out AzureVMWorkloadSAPAseDatabaseWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseDatabaseWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPAseSystem") { + var out AzureVMWorkloadSAPAseSystemWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseSystemWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaDatabase") { + var out AzureVMWorkloadSAPHanaDatabaseWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDatabaseWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaSystem") { + var out AzureVMWorkloadSAPHanaSystemWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaSystemWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLDataBase") { + var out AzureVMWorkloadSQLDatabaseWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLDatabaseWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLInstance") { + var out AzureVMWorkloadSQLInstanceWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLInstanceWorkloadItem: %+v", err) + } + return out, nil + } + + var parent BaseWorkloadItemImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseWorkloadItemImpl: %+v", err) + } + + return RawWorkloadItemImpl{ + workloadItem: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_workloaditemresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_workloaditemresource.go new file mode 100644 index 00000000000..4cea6b568cc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/model_workloaditemresource.go @@ -0,0 +1,57 @@ +package backupworkloaditems + +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 WorkloadItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkloadItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &WorkloadItemResource{} + +func (s *WorkloadItemResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 WorkloadItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalWorkloadItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'WorkloadItemResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/predicates.go new file mode 100644 index 00000000000..98e6f2ee1de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/predicates.go @@ -0,0 +1,37 @@ +package backupworkloaditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadItemResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkloadItemResourceOperationPredicate) Matches(input WorkloadItemResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/version.go new file mode 100644 index 00000000000..4820d9c53b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems/version.go @@ -0,0 +1,10 @@ +package backupworkloaditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupworkloaditems/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/client.go new file mode 100644 index 00000000000..ba551849a56 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/client.go @@ -0,0 +1,239 @@ +package v2024_10_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupengines" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupjobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backuppolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectableitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupprotecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupprotectionintent" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupresourceencryptionconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcestorageconfigsnoncrr" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupresourcevaultconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backups" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupstatus" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupusagesummaries" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/backupworkloaditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/datamove" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/jobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/operation" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/restores" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/securitypins" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation" +) + +type Client struct { + BackupEngines *backupengines.BackupEnginesClient + BackupJobs *backupjobs.BackupJobsClient + BackupPolicies *backuppolicies.BackupPoliciesClient + BackupProtectableItems *backupprotectableitems.BackupProtectableItemsClient + BackupProtectedItems *backupprotecteditems.BackupProtectedItemsClient + BackupProtectionContainers *backupprotectioncontainers.BackupProtectionContainersClient + BackupProtectionIntent *backupprotectionintent.BackupProtectionIntentClient + BackupResourceEncryptionConfigs *backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient + BackupResourceStorageConfigsNonCRR *backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient + BackupResourceVaultConfigs *backupresourcevaultconfigs.BackupResourceVaultConfigsClient + BackupStatus *backupstatus.BackupStatusClient + BackupUsageSummaries *backupusagesummaries.BackupUsageSummariesClient + BackupWorkloadItems *backupworkloaditems.BackupWorkloadItemsClient + Backups *backups.BackupsClient + DataMove *datamove.DataMoveClient + FeatureSupport *featuresupport.FeatureSupportClient + FetchTieringCost *fetchtieringcost.FetchTieringCostClient + ItemLevelRecoveryConnections *itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient + JobCancellations *jobcancellations.JobCancellationsClient + JobDetails *jobdetails.JobDetailsClient + Jobs *jobs.JobsClient + Operation *operation.OperationClient + PrivateEndpointConnection *privateendpointconnection.PrivateEndpointConnectionClient + ProtectableContainers *protectablecontainers.ProtectableContainersClient + ProtectedItems *protecteditems.ProtectedItemsClient + ProtectionContainers *protectioncontainers.ProtectionContainersClient + ProtectionIntent *protectionintent.ProtectionIntentClient + ProtectionPolicies *protectionpolicies.ProtectionPoliciesClient + RecoveryPoint *recoverypoint.RecoveryPointClient + RecoveryPoints *recoverypoints.RecoveryPointsClient + RecoveryPointsRecommendedForMove *recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient + ResourceGuardProxies *resourceguardproxies.ResourceGuardProxiesClient + ResourceGuardProxy *resourceguardproxy.ResourceGuardProxyClient + Restores *restores.RestoresClient + SecurityPINs *securitypins.SecurityPINsClient + SoftDeletedContainers *softdeletedcontainers.SoftDeletedContainersClient + ValidateOperation *validateoperation.ValidateOperationClient +} + +func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { + + backupEnginesClient := backupengines.NewBackupEnginesClientWithBaseURI(endpoint) + configureAuthFunc(&backupEnginesClient.Client) + + backupJobsClient := backupjobs.NewBackupJobsClientWithBaseURI(endpoint) + configureAuthFunc(&backupJobsClient.Client) + + backupPoliciesClient := backuppolicies.NewBackupPoliciesClientWithBaseURI(endpoint) + configureAuthFunc(&backupPoliciesClient.Client) + + backupProtectableItemsClient := backupprotectableitems.NewBackupProtectableItemsClientWithBaseURI(endpoint) + configureAuthFunc(&backupProtectableItemsClient.Client) + + backupProtectedItemsClient := backupprotecteditems.NewBackupProtectedItemsClientWithBaseURI(endpoint) + configureAuthFunc(&backupProtectedItemsClient.Client) + + backupProtectionContainersClient := backupprotectioncontainers.NewBackupProtectionContainersClientWithBaseURI(endpoint) + configureAuthFunc(&backupProtectionContainersClient.Client) + + backupProtectionIntentClient := backupprotectionintent.NewBackupProtectionIntentClientWithBaseURI(endpoint) + configureAuthFunc(&backupProtectionIntentClient.Client) + + backupResourceEncryptionConfigsClient := backupresourceencryptionconfigs.NewBackupResourceEncryptionConfigsClientWithBaseURI(endpoint) + configureAuthFunc(&backupResourceEncryptionConfigsClient.Client) + + backupResourceStorageConfigsNonCRRClient := backupresourcestorageconfigsnoncrr.NewBackupResourceStorageConfigsNonCRRClientWithBaseURI(endpoint) + configureAuthFunc(&backupResourceStorageConfigsNonCRRClient.Client) + + backupResourceVaultConfigsClient := backupresourcevaultconfigs.NewBackupResourceVaultConfigsClientWithBaseURI(endpoint) + configureAuthFunc(&backupResourceVaultConfigsClient.Client) + + backupStatusClient := backupstatus.NewBackupStatusClientWithBaseURI(endpoint) + configureAuthFunc(&backupStatusClient.Client) + + backupUsageSummariesClient := backupusagesummaries.NewBackupUsageSummariesClientWithBaseURI(endpoint) + configureAuthFunc(&backupUsageSummariesClient.Client) + + backupWorkloadItemsClient := backupworkloaditems.NewBackupWorkloadItemsClientWithBaseURI(endpoint) + configureAuthFunc(&backupWorkloadItemsClient.Client) + + backupsClient := backups.NewBackupsClientWithBaseURI(endpoint) + configureAuthFunc(&backupsClient.Client) + + dataMoveClient := datamove.NewDataMoveClientWithBaseURI(endpoint) + configureAuthFunc(&dataMoveClient.Client) + + featureSupportClient := featuresupport.NewFeatureSupportClientWithBaseURI(endpoint) + configureAuthFunc(&featureSupportClient.Client) + + fetchTieringCostClient := fetchtieringcost.NewFetchTieringCostClientWithBaseURI(endpoint) + configureAuthFunc(&fetchTieringCostClient.Client) + + itemLevelRecoveryConnectionsClient := itemlevelrecoveryconnections.NewItemLevelRecoveryConnectionsClientWithBaseURI(endpoint) + configureAuthFunc(&itemLevelRecoveryConnectionsClient.Client) + + jobCancellationsClient := jobcancellations.NewJobCancellationsClientWithBaseURI(endpoint) + configureAuthFunc(&jobCancellationsClient.Client) + + jobDetailsClient := jobdetails.NewJobDetailsClientWithBaseURI(endpoint) + configureAuthFunc(&jobDetailsClient.Client) + + jobsClient := jobs.NewJobsClientWithBaseURI(endpoint) + configureAuthFunc(&jobsClient.Client) + + operationClient := operation.NewOperationClientWithBaseURI(endpoint) + configureAuthFunc(&operationClient.Client) + + privateEndpointConnectionClient := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI(endpoint) + configureAuthFunc(&privateEndpointConnectionClient.Client) + + protectableContainersClient := protectablecontainers.NewProtectableContainersClientWithBaseURI(endpoint) + configureAuthFunc(&protectableContainersClient.Client) + + protectedItemsClient := protecteditems.NewProtectedItemsClientWithBaseURI(endpoint) + configureAuthFunc(&protectedItemsClient.Client) + + protectionContainersClient := protectioncontainers.NewProtectionContainersClientWithBaseURI(endpoint) + configureAuthFunc(&protectionContainersClient.Client) + + protectionIntentClient := protectionintent.NewProtectionIntentClientWithBaseURI(endpoint) + configureAuthFunc(&protectionIntentClient.Client) + + protectionPoliciesClient := protectionpolicies.NewProtectionPoliciesClientWithBaseURI(endpoint) + configureAuthFunc(&protectionPoliciesClient.Client) + + recoveryPointClient := recoverypoint.NewRecoveryPointClientWithBaseURI(endpoint) + configureAuthFunc(&recoveryPointClient.Client) + + recoveryPointsClient := recoverypoints.NewRecoveryPointsClientWithBaseURI(endpoint) + configureAuthFunc(&recoveryPointsClient.Client) + + recoveryPointsRecommendedForMoveClient := recoverypointsrecommendedformove.NewRecoveryPointsRecommendedForMoveClientWithBaseURI(endpoint) + configureAuthFunc(&recoveryPointsRecommendedForMoveClient.Client) + + resourceGuardProxiesClient := resourceguardproxies.NewResourceGuardProxiesClientWithBaseURI(endpoint) + configureAuthFunc(&resourceGuardProxiesClient.Client) + + resourceGuardProxyClient := resourceguardproxy.NewResourceGuardProxyClientWithBaseURI(endpoint) + configureAuthFunc(&resourceGuardProxyClient.Client) + + restoresClient := restores.NewRestoresClientWithBaseURI(endpoint) + configureAuthFunc(&restoresClient.Client) + + securityPINsClient := securitypins.NewSecurityPINsClientWithBaseURI(endpoint) + configureAuthFunc(&securityPINsClient.Client) + + softDeletedContainersClient := softdeletedcontainers.NewSoftDeletedContainersClientWithBaseURI(endpoint) + configureAuthFunc(&softDeletedContainersClient.Client) + + validateOperationClient := validateoperation.NewValidateOperationClientWithBaseURI(endpoint) + configureAuthFunc(&validateOperationClient.Client) + + return Client{ + BackupEngines: &backupEnginesClient, + BackupJobs: &backupJobsClient, + BackupPolicies: &backupPoliciesClient, + BackupProtectableItems: &backupProtectableItemsClient, + BackupProtectedItems: &backupProtectedItemsClient, + BackupProtectionContainers: &backupProtectionContainersClient, + BackupProtectionIntent: &backupProtectionIntentClient, + BackupResourceEncryptionConfigs: &backupResourceEncryptionConfigsClient, + BackupResourceStorageConfigsNonCRR: &backupResourceStorageConfigsNonCRRClient, + BackupResourceVaultConfigs: &backupResourceVaultConfigsClient, + BackupStatus: &backupStatusClient, + BackupUsageSummaries: &backupUsageSummariesClient, + BackupWorkloadItems: &backupWorkloadItemsClient, + Backups: &backupsClient, + DataMove: &dataMoveClient, + FeatureSupport: &featureSupportClient, + FetchTieringCost: &fetchTieringCostClient, + ItemLevelRecoveryConnections: &itemLevelRecoveryConnectionsClient, + JobCancellations: &jobCancellationsClient, + JobDetails: &jobDetailsClient, + Jobs: &jobsClient, + Operation: &operationClient, + PrivateEndpointConnection: &privateEndpointConnectionClient, + ProtectableContainers: &protectableContainersClient, + ProtectedItems: &protectedItemsClient, + ProtectionContainers: &protectionContainersClient, + ProtectionIntent: &protectionIntentClient, + ProtectionPolicies: &protectionPoliciesClient, + RecoveryPoint: &recoveryPointClient, + RecoveryPoints: &recoveryPointsClient, + RecoveryPointsRecommendedForMove: &recoveryPointsRecommendedForMoveClient, + ResourceGuardProxies: &resourceGuardProxiesClient, + ResourceGuardProxy: &resourceGuardProxyClient, + Restores: &restoresClient, + SecurityPINs: &securityPINsClient, + SoftDeletedContainers: &softDeletedContainersClient, + ValidateOperation: &validateOperationClient, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/datamove/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/README.md new file mode 100644 index 00000000000..235edb24648 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/datamove` Documentation + +The `datamove` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/datamove" +``` + + +### Client Initialization + +```go +client := datamove.NewDataMoveClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataMoveClient.BMSPrepareDataMove` + +```go +ctx := context.TODO() +id := datamove.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := datamove.PrepareDataMoveRequest{ + // ... +} + + +if err := client.BMSPrepareDataMoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataMoveClient.BMSTriggerDataMove` + +```go +ctx := context.TODO() +id := datamove.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := datamove.TriggerDataMoveRequest{ + // ... +} + + +if err := client.BMSTriggerDataMoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/datamove/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/client.go new file mode 100644 index 00000000000..bca13a32cd6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/client.go @@ -0,0 +1,18 @@ +package datamove + +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 DataMoveClient struct { + Client autorest.Client + baseUri string +} + +func NewDataMoveClientWithBaseURI(endpoint string) DataMoveClient { + return DataMoveClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/datamove/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/constants.go new file mode 100644 index 00000000000..394d00d9a0f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/constants.go @@ -0,0 +1,39 @@ +package datamove + +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 DataMoveLevel string + +const ( + DataMoveLevelContainer DataMoveLevel = "Container" + DataMoveLevelInvalid DataMoveLevel = "Invalid" + DataMoveLevelVault DataMoveLevel = "Vault" +) + +func PossibleValuesForDataMoveLevel() []string { + return []string{ + string(DataMoveLevelContainer), + string(DataMoveLevelInvalid), + string(DataMoveLevelVault), + } +} + +func parseDataMoveLevel(input string) (*DataMoveLevel, error) { + vals := map[string]DataMoveLevel{ + "container": DataMoveLevelContainer, + "invalid": DataMoveLevelInvalid, + "vault": DataMoveLevelVault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataMoveLevel(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/datamove/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/id_vault.go new file mode 100644 index 00000000000..b2b8b1a07c2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/id_vault.go @@ -0,0 +1,130 @@ +package datamove + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/datamove/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/id_vault_test.go new file mode 100644 index 00000000000..03a886c800d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/id_vault_test.go @@ -0,0 +1,282 @@ +package datamove + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/datamove/method_bmspreparedatamove_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/method_bmspreparedatamove_autorest.go new file mode 100644 index 00000000000..460642bf637 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/method_bmspreparedatamove_autorest.go @@ -0,0 +1,79 @@ +package datamove + +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 BMSPrepareDataMoveOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// BMSPrepareDataMove ... +func (c DataMoveClient) BMSPrepareDataMove(ctx context.Context, id VaultId, input PrepareDataMoveRequest) (result BMSPrepareDataMoveOperationResponse, err error) { + req, err := c.preparerForBMSPrepareDataMove(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "datamove.DataMoveClient", "BMSPrepareDataMove", nil, "Failure preparing request") + return + } + + result, err = c.senderForBMSPrepareDataMove(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "datamove.DataMoveClient", "BMSPrepareDataMove", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// BMSPrepareDataMoveThenPoll performs BMSPrepareDataMove then polls until it's completed +func (c DataMoveClient) BMSPrepareDataMoveThenPoll(ctx context.Context, id VaultId, input PrepareDataMoveRequest) error { + result, err := c.BMSPrepareDataMove(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BMSPrepareDataMove: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after BMSPrepareDataMove: %+v", err) + } + + return nil +} + +// preparerForBMSPrepareDataMove prepares the BMSPrepareDataMove request. +func (c DataMoveClient) preparerForBMSPrepareDataMove(ctx context.Context, id VaultId, input PrepareDataMoveRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig/prepareDataMove", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForBMSPrepareDataMove sends the BMSPrepareDataMove request. The method will close the +// http.Response Body if it receives an error. +func (c DataMoveClient) senderForBMSPrepareDataMove(ctx context.Context, req *http.Request) (future BMSPrepareDataMoveOperationResponse, 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/resource-manager/recoveryservicesbackup/2024-10-01/datamove/method_bmstriggerdatamove_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/method_bmstriggerdatamove_autorest.go new file mode 100644 index 00000000000..5f89d916019 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/method_bmstriggerdatamove_autorest.go @@ -0,0 +1,79 @@ +package datamove + +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 BMSTriggerDataMoveOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// BMSTriggerDataMove ... +func (c DataMoveClient) BMSTriggerDataMove(ctx context.Context, id VaultId, input TriggerDataMoveRequest) (result BMSTriggerDataMoveOperationResponse, err error) { + req, err := c.preparerForBMSTriggerDataMove(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "datamove.DataMoveClient", "BMSTriggerDataMove", nil, "Failure preparing request") + return + } + + result, err = c.senderForBMSTriggerDataMove(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "datamove.DataMoveClient", "BMSTriggerDataMove", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// BMSTriggerDataMoveThenPoll performs BMSTriggerDataMove then polls until it's completed +func (c DataMoveClient) BMSTriggerDataMoveThenPoll(ctx context.Context, id VaultId, input TriggerDataMoveRequest) error { + result, err := c.BMSTriggerDataMove(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BMSTriggerDataMove: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after BMSTriggerDataMove: %+v", err) + } + + return nil +} + +// preparerForBMSTriggerDataMove prepares the BMSTriggerDataMove request. +func (c DataMoveClient) preparerForBMSTriggerDataMove(ctx context.Context, id VaultId, input TriggerDataMoveRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig/triggerDataMove", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForBMSTriggerDataMove sends the BMSTriggerDataMove request. The method will close the +// http.Response Body if it receives an error. +func (c DataMoveClient) senderForBMSTriggerDataMove(ctx context.Context, req *http.Request) (future BMSTriggerDataMoveOperationResponse, 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/resource-manager/recoveryservicesbackup/2024-10-01/datamove/model_preparedatamoverequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/model_preparedatamoverequest.go new file mode 100644 index 00000000000..f2e39d1cd8a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/model_preparedatamoverequest.go @@ -0,0 +1,12 @@ +package datamove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrepareDataMoveRequest struct { + DataMoveLevel DataMoveLevel `json:"dataMoveLevel"` + IgnoreMoved *bool `json:"ignoreMoved,omitempty"` + SourceContainerArmIds *[]string `json:"sourceContainerArmIds,omitempty"` + TargetRegion string `json:"targetRegion"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/datamove/model_triggerdatamoverequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/model_triggerdatamoverequest.go new file mode 100644 index 00000000000..eb35ce70218 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/model_triggerdatamoverequest.go @@ -0,0 +1,13 @@ +package datamove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggerDataMoveRequest struct { + CorrelationId string `json:"correlationId"` + DataMoveLevel DataMoveLevel `json:"dataMoveLevel"` + PauseGC *bool `json:"pauseGC,omitempty"` + SourceContainerArmIds *[]string `json:"sourceContainerArmIds,omitempty"` + SourceRegion string `json:"sourceRegion"` + SourceResourceId string `json:"sourceResourceId"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/datamove/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/version.go new file mode 100644 index 00000000000..6bc948fed50 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/datamove/version.go @@ -0,0 +1,10 @@ +package datamove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/datamove/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/README.md new file mode 100644 index 00000000000..2517f95ddd6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport` Documentation + +The `featuresupport` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/featuresupport" +``` + + +### Client Initialization + +```go +client := featuresupport.NewFeatureSupportClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FeatureSupportClient.Validate` + +```go +ctx := context.TODO() +id := featuresupport.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := featuresupport.FeatureSupportRequest{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/client.go new file mode 100644 index 00000000000..b4f22ceed18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/client.go @@ -0,0 +1,18 @@ +package featuresupport + +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 FeatureSupportClient struct { + Client autorest.Client + baseUri string +} + +func NewFeatureSupportClientWithBaseURI(endpoint string) FeatureSupportClient { + return FeatureSupportClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/constants.go new file mode 100644 index 00000000000..de57933a730 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/constants.go @@ -0,0 +1,45 @@ +package featuresupport + +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 SupportStatus string + +const ( + SupportStatusDefaultOFF SupportStatus = "DefaultOFF" + SupportStatusDefaultON SupportStatus = "DefaultON" + SupportStatusInvalid SupportStatus = "Invalid" + SupportStatusNotSupported SupportStatus = "NotSupported" + SupportStatusSupported SupportStatus = "Supported" +) + +func PossibleValuesForSupportStatus() []string { + return []string{ + string(SupportStatusDefaultOFF), + string(SupportStatusDefaultON), + string(SupportStatusInvalid), + string(SupportStatusNotSupported), + string(SupportStatusSupported), + } +} + +func parseSupportStatus(input string) (*SupportStatus, error) { + vals := map[string]SupportStatus{ + "defaultoff": SupportStatusDefaultOFF, + "defaulton": SupportStatusDefaultON, + "invalid": SupportStatusInvalid, + "notsupported": SupportStatusNotSupported, + "supported": SupportStatusSupported, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/id_location.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/id_location.go new file mode 100644 index 00000000000..8347c40e5d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/id_location.go @@ -0,0 +1,121 @@ +package featuresupport + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/id_location_test.go new file mode 100644 index 00000000000..c8e2c22eea9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/id_location_test.go @@ -0,0 +1,237 @@ +package featuresupport + +import ( + "testing" + + "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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/method_validate_autorest.go new file mode 100644 index 00000000000..71e04fc843f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/method_validate_autorest.go @@ -0,0 +1,70 @@ +package featuresupport + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + HttpResponse *http.Response + Model *AzureVMResourceFeatureSupportResponse +} + +// Validate ... +func (c FeatureSupportClient) Validate(ctx context.Context, id LocationId, input FeatureSupportRequest) (result ValidateOperationResponse, err error) { + req, err := c.preparerForValidate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "featuresupport.FeatureSupportClient", "Validate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "featuresupport.FeatureSupportClient", "Validate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForValidate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "featuresupport.FeatureSupportClient", "Validate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForValidate prepares the Validate request. +func (c FeatureSupportClient) preparerForValidate(ctx context.Context, id LocationId, input FeatureSupportRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupValidateFeatures", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForValidate handles the response to the Validate request. The method always +// closes the http.Response Body. +func (c FeatureSupportClient) responderForValidate(resp *http.Response) (result ValidateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go new file mode 100644 index 00000000000..ecc777b3d84 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go @@ -0,0 +1,49 @@ +package featuresupport + +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 _ FeatureSupportRequest = AzureBackupGoalFeatureSupportRequest{} + +type AzureBackupGoalFeatureSupportRequest struct { + + // Fields inherited from FeatureSupportRequest + + FeatureType string `json:"featureType"` +} + +func (s AzureBackupGoalFeatureSupportRequest) FeatureSupportRequest() BaseFeatureSupportRequestImpl { + return BaseFeatureSupportRequestImpl{ + FeatureType: s.FeatureType, + } +} + +var _ json.Marshaler = AzureBackupGoalFeatureSupportRequest{} + +func (s AzureBackupGoalFeatureSupportRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupGoalFeatureSupportRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupGoalFeatureSupportRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupGoalFeatureSupportRequest: %+v", err) + } + + decoded["featureType"] = "AzureBackupGoals" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupGoalFeatureSupportRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go new file mode 100644 index 00000000000..691dba6c83b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go @@ -0,0 +1,51 @@ +package featuresupport + +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 _ FeatureSupportRequest = AzureVMResourceFeatureSupportRequest{} + +type AzureVMResourceFeatureSupportRequest struct { + VMSize *string `json:"vmSize,omitempty"` + VMSku *string `json:"vmSku,omitempty"` + + // Fields inherited from FeatureSupportRequest + + FeatureType string `json:"featureType"` +} + +func (s AzureVMResourceFeatureSupportRequest) FeatureSupportRequest() BaseFeatureSupportRequestImpl { + return BaseFeatureSupportRequestImpl{ + FeatureType: s.FeatureType, + } +} + +var _ json.Marshaler = AzureVMResourceFeatureSupportRequest{} + +func (s AzureVMResourceFeatureSupportRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureVMResourceFeatureSupportRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMResourceFeatureSupportRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMResourceFeatureSupportRequest: %+v", err) + } + + decoded["featureType"] = "AzureVMResourceBackup" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMResourceFeatureSupportRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go new file mode 100644 index 00000000000..b9d8a42e54a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go @@ -0,0 +1,8 @@ +package featuresupport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMResourceFeatureSupportResponse struct { + SupportStatus *SupportStatus `json:"supportStatus,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_featuresupportrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_featuresupportrequest.go new file mode 100644 index 00000000000..2b8b431466e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/model_featuresupportrequest.go @@ -0,0 +1,83 @@ +package featuresupport + +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 FeatureSupportRequest interface { + FeatureSupportRequest() BaseFeatureSupportRequestImpl +} + +var _ FeatureSupportRequest = BaseFeatureSupportRequestImpl{} + +type BaseFeatureSupportRequestImpl struct { + FeatureType string `json:"featureType"` +} + +func (s BaseFeatureSupportRequestImpl) FeatureSupportRequest() BaseFeatureSupportRequestImpl { + return s +} + +var _ FeatureSupportRequest = RawFeatureSupportRequestImpl{} + +// RawFeatureSupportRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawFeatureSupportRequestImpl struct { + featureSupportRequest BaseFeatureSupportRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawFeatureSupportRequestImpl) FeatureSupportRequest() BaseFeatureSupportRequestImpl { + return s.featureSupportRequest +} + +func UnmarshalFeatureSupportRequestImplementation(input []byte) (FeatureSupportRequest, 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 FeatureSupportRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["featureType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureBackupGoals") { + var out AzureBackupGoalFeatureSupportRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupGoalFeatureSupportRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVMResourceBackup") { + var out AzureVMResourceFeatureSupportRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMResourceFeatureSupportRequest: %+v", err) + } + return out, nil + } + + var parent BaseFeatureSupportRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFeatureSupportRequestImpl: %+v", err) + } + + return RawFeatureSupportRequestImpl{ + featureSupportRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/version.go new file mode 100644 index 00000000000..a1cd3e912d0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/featuresupport/version.go @@ -0,0 +1,10 @@ +package featuresupport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/featuresupport/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/README.md new file mode 100644 index 00000000000..7b944814b2e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost` Documentation + +The `fetchtieringcost` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/fetchtieringcost" +``` + + +### Client Initialization + +```go +client := fetchtieringcost.NewFetchTieringCostClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FetchTieringCostClient.Post` + +```go +ctx := context.TODO() +id := fetchtieringcost.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := fetchtieringcost.FetchTieringCostInfoRequest{ + // ... +} + + +if err := client.PostThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/client.go new file mode 100644 index 00000000000..c3df44f183a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/client.go @@ -0,0 +1,18 @@ +package fetchtieringcost + +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 FetchTieringCostClient struct { + Client autorest.Client + baseUri string +} + +func NewFetchTieringCostClientWithBaseURI(endpoint string) FetchTieringCostClient { + return FetchTieringCostClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/constants.go new file mode 100644 index 00000000000..7dcbbbe9712 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/constants.go @@ -0,0 +1,70 @@ +package fetchtieringcost + +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 RecoveryPointTierType string + +const ( + RecoveryPointTierTypeArchivedRP RecoveryPointTierType = "ArchivedRP" + RecoveryPointTierTypeHardenedRP RecoveryPointTierType = "HardenedRP" + RecoveryPointTierTypeInstantRP RecoveryPointTierType = "InstantRP" + RecoveryPointTierTypeInvalid RecoveryPointTierType = "Invalid" +) + +func PossibleValuesForRecoveryPointTierType() []string { + return []string{ + string(RecoveryPointTierTypeArchivedRP), + string(RecoveryPointTierTypeHardenedRP), + string(RecoveryPointTierTypeInstantRP), + string(RecoveryPointTierTypeInvalid), + } +} + +func parseRecoveryPointTierType(input string) (*RecoveryPointTierType, error) { + vals := map[string]RecoveryPointTierType{ + "archivedrp": RecoveryPointTierTypeArchivedRP, + "hardenedrp": RecoveryPointTierTypeHardenedRP, + "instantrp": RecoveryPointTierTypeInstantRP, + "invalid": RecoveryPointTierTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierType(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityStandard), + } +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/id_vault.go new file mode 100644 index 00000000000..b4b71eafca4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/id_vault.go @@ -0,0 +1,130 @@ +package fetchtieringcost + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/id_vault_test.go new file mode 100644 index 00000000000..995ddf194df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/id_vault_test.go @@ -0,0 +1,282 @@ +package fetchtieringcost + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/method_post_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/method_post_autorest.go new file mode 100644 index 00000000000..388a3bbc273 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/method_post_autorest.go @@ -0,0 +1,80 @@ +package fetchtieringcost + +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 PostOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response + Model *TieringCostInfo +} + +// Post ... +func (c FetchTieringCostClient) Post(ctx context.Context, id VaultId, input FetchTieringCostInfoRequest) (result PostOperationResponse, err error) { + req, err := c.preparerForPost(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fetchtieringcost.FetchTieringCostClient", "Post", nil, "Failure preparing request") + return + } + + result, err = c.senderForPost(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "fetchtieringcost.FetchTieringCostClient", "Post", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// PostThenPoll performs Post then polls until it's completed +func (c FetchTieringCostClient) PostThenPoll(ctx context.Context, id VaultId, input FetchTieringCostInfoRequest) error { + result, err := c.Post(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Post: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Post: %+v", err) + } + + return nil +} + +// preparerForPost prepares the Post request. +func (c FetchTieringCostClient) preparerForPost(ctx context.Context, id VaultId, input FetchTieringCostInfoRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupTieringCost/default/fetchTieringCost", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForPost sends the Post request. The method will close the +// http.Response Body if it receives an error. +func (c FetchTieringCostClient) senderForPost(ctx context.Context, req *http.Request) (future PostOperationResponse, 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/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go new file mode 100644 index 00000000000..4fb183b3f41 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go @@ -0,0 +1,57 @@ +package fetchtieringcost + +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 _ FetchTieringCostInfoRequest = FetchTieringCostInfoForRehydrationRequest{} + +type FetchTieringCostInfoForRehydrationRequest struct { + ContainerName string `json:"containerName"` + ProtectedItemName string `json:"protectedItemName"` + RecoveryPointId string `json:"recoveryPointId"` + RehydrationPriority RehydrationPriority `json:"rehydrationPriority"` + + // Fields inherited from FetchTieringCostInfoRequest + + ObjectType string `json:"objectType"` + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +func (s FetchTieringCostInfoForRehydrationRequest) FetchTieringCostInfoRequest() BaseFetchTieringCostInfoRequestImpl { + return BaseFetchTieringCostInfoRequestImpl{ + ObjectType: s.ObjectType, + SourceTierType: s.SourceTierType, + TargetTierType: s.TargetTierType, + } +} + +var _ json.Marshaler = FetchTieringCostInfoForRehydrationRequest{} + +func (s FetchTieringCostInfoForRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper FetchTieringCostInfoForRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FetchTieringCostInfoForRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostInfoForRehydrationRequest: %+v", err) + } + + decoded["objectType"] = "FetchTieringCostInfoForRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FetchTieringCostInfoForRehydrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostinforequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostinforequest.go new file mode 100644 index 00000000000..1d6371e8a60 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostinforequest.go @@ -0,0 +1,101 @@ +package fetchtieringcost + +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 FetchTieringCostInfoRequest interface { + FetchTieringCostInfoRequest() BaseFetchTieringCostInfoRequestImpl +} + +var _ FetchTieringCostInfoRequest = BaseFetchTieringCostInfoRequestImpl{} + +type BaseFetchTieringCostInfoRequestImpl struct { + ObjectType string `json:"objectType"` + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +func (s BaseFetchTieringCostInfoRequestImpl) FetchTieringCostInfoRequest() BaseFetchTieringCostInfoRequestImpl { + return s +} + +var _ FetchTieringCostInfoRequest = RawFetchTieringCostInfoRequestImpl{} + +// RawFetchTieringCostInfoRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawFetchTieringCostInfoRequestImpl struct { + fetchTieringCostInfoRequest BaseFetchTieringCostInfoRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawFetchTieringCostInfoRequestImpl) FetchTieringCostInfoRequest() BaseFetchTieringCostInfoRequestImpl { + return s.fetchTieringCostInfoRequest +} + +func UnmarshalFetchTieringCostInfoRequestImplementation(input []byte) (FetchTieringCostInfoRequest, 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 FetchTieringCostInfoRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FetchTieringCostInfoForRehydrationRequest") { + var out FetchTieringCostInfoForRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FetchTieringCostInfoForRehydrationRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FetchTieringCostSavingsInfoForPolicyRequest") { + var out FetchTieringCostSavingsInfoForPolicyRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FetchTieringCostSavingsInfoForPolicyRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FetchTieringCostSavingsInfoForProtectedItemRequest") { + var out FetchTieringCostSavingsInfoForProtectedItemRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FetchTieringCostSavingsInfoForProtectedItemRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FetchTieringCostSavingsInfoForVaultRequest") { + var out FetchTieringCostSavingsInfoForVaultRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FetchTieringCostSavingsInfoForVaultRequest: %+v", err) + } + return out, nil + } + + var parent BaseFetchTieringCostInfoRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFetchTieringCostInfoRequestImpl: %+v", err) + } + + return RawFetchTieringCostInfoRequestImpl{ + fetchTieringCostInfoRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go new file mode 100644 index 00000000000..e9c6afb7a3a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go @@ -0,0 +1,54 @@ +package fetchtieringcost + +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 _ FetchTieringCostInfoRequest = FetchTieringCostSavingsInfoForPolicyRequest{} + +type FetchTieringCostSavingsInfoForPolicyRequest struct { + PolicyName string `json:"policyName"` + + // Fields inherited from FetchTieringCostInfoRequest + + ObjectType string `json:"objectType"` + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +func (s FetchTieringCostSavingsInfoForPolicyRequest) FetchTieringCostInfoRequest() BaseFetchTieringCostInfoRequestImpl { + return BaseFetchTieringCostInfoRequestImpl{ + ObjectType: s.ObjectType, + SourceTierType: s.SourceTierType, + TargetTierType: s.TargetTierType, + } +} + +var _ json.Marshaler = FetchTieringCostSavingsInfoForPolicyRequest{} + +func (s FetchTieringCostSavingsInfoForPolicyRequest) MarshalJSON() ([]byte, error) { + type wrapper FetchTieringCostSavingsInfoForPolicyRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FetchTieringCostSavingsInfoForPolicyRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostSavingsInfoForPolicyRequest: %+v", err) + } + + decoded["objectType"] = "FetchTieringCostSavingsInfoForPolicyRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FetchTieringCostSavingsInfoForPolicyRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go new file mode 100644 index 00000000000..26bebb45e79 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go @@ -0,0 +1,55 @@ +package fetchtieringcost + +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 _ FetchTieringCostInfoRequest = FetchTieringCostSavingsInfoForProtectedItemRequest{} + +type FetchTieringCostSavingsInfoForProtectedItemRequest struct { + ContainerName string `json:"containerName"` + ProtectedItemName string `json:"protectedItemName"` + + // Fields inherited from FetchTieringCostInfoRequest + + ObjectType string `json:"objectType"` + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +func (s FetchTieringCostSavingsInfoForProtectedItemRequest) FetchTieringCostInfoRequest() BaseFetchTieringCostInfoRequestImpl { + return BaseFetchTieringCostInfoRequestImpl{ + ObjectType: s.ObjectType, + SourceTierType: s.SourceTierType, + TargetTierType: s.TargetTierType, + } +} + +var _ json.Marshaler = FetchTieringCostSavingsInfoForProtectedItemRequest{} + +func (s FetchTieringCostSavingsInfoForProtectedItemRequest) MarshalJSON() ([]byte, error) { + type wrapper FetchTieringCostSavingsInfoForProtectedItemRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FetchTieringCostSavingsInfoForProtectedItemRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostSavingsInfoForProtectedItemRequest: %+v", err) + } + + decoded["objectType"] = "FetchTieringCostSavingsInfoForProtectedItemRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FetchTieringCostSavingsInfoForProtectedItemRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go new file mode 100644 index 00000000000..16df6347d82 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go @@ -0,0 +1,53 @@ +package fetchtieringcost + +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 _ FetchTieringCostInfoRequest = FetchTieringCostSavingsInfoForVaultRequest{} + +type FetchTieringCostSavingsInfoForVaultRequest struct { + + // Fields inherited from FetchTieringCostInfoRequest + + ObjectType string `json:"objectType"` + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +func (s FetchTieringCostSavingsInfoForVaultRequest) FetchTieringCostInfoRequest() BaseFetchTieringCostInfoRequestImpl { + return BaseFetchTieringCostInfoRequestImpl{ + ObjectType: s.ObjectType, + SourceTierType: s.SourceTierType, + TargetTierType: s.TargetTierType, + } +} + +var _ json.Marshaler = FetchTieringCostSavingsInfoForVaultRequest{} + +func (s FetchTieringCostSavingsInfoForVaultRequest) MarshalJSON() ([]byte, error) { + type wrapper FetchTieringCostSavingsInfoForVaultRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FetchTieringCostSavingsInfoForVaultRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostSavingsInfoForVaultRequest: %+v", err) + } + + decoded["objectType"] = "FetchTieringCostSavingsInfoForVaultRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FetchTieringCostSavingsInfoForVaultRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostinfo.go new file mode 100644 index 00000000000..d0e495ce0f4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostinfo.go @@ -0,0 +1,83 @@ +package fetchtieringcost + +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 TieringCostInfo interface { + TieringCostInfo() BaseTieringCostInfoImpl +} + +var _ TieringCostInfo = BaseTieringCostInfoImpl{} + +type BaseTieringCostInfoImpl struct { + ObjectType string `json:"objectType"` +} + +func (s BaseTieringCostInfoImpl) TieringCostInfo() BaseTieringCostInfoImpl { + return s +} + +var _ TieringCostInfo = RawTieringCostInfoImpl{} + +// RawTieringCostInfoImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawTieringCostInfoImpl struct { + tieringCostInfo BaseTieringCostInfoImpl + Type string + Values map[string]interface{} +} + +func (s RawTieringCostInfoImpl) TieringCostInfo() BaseTieringCostInfoImpl { + return s.tieringCostInfo +} + +func UnmarshalTieringCostInfoImplementation(input []byte) (TieringCostInfo, 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 TieringCostInfo into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "TieringCostRehydrationInfo") { + var out TieringCostRehydrationInfo + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TieringCostRehydrationInfo: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TieringCostSavingInfo") { + var out TieringCostSavingInfo + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TieringCostSavingInfo: %+v", err) + } + return out, nil + } + + var parent BaseTieringCostInfoImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTieringCostInfoImpl: %+v", err) + } + + return RawTieringCostInfoImpl{ + tieringCostInfo: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostrehydrationinfo.go new file mode 100644 index 00000000000..1fe2415f033 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostrehydrationinfo.go @@ -0,0 +1,51 @@ +package fetchtieringcost + +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 _ TieringCostInfo = TieringCostRehydrationInfo{} + +type TieringCostRehydrationInfo struct { + RehydrationSizeInBytes int64 `json:"rehydrationSizeInBytes"` + RetailRehydrationCostPerGBPerMonth float64 `json:"retailRehydrationCostPerGBPerMonth"` + + // Fields inherited from TieringCostInfo + + ObjectType string `json:"objectType"` +} + +func (s TieringCostRehydrationInfo) TieringCostInfo() BaseTieringCostInfoImpl { + return BaseTieringCostInfoImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = TieringCostRehydrationInfo{} + +func (s TieringCostRehydrationInfo) MarshalJSON() ([]byte, error) { + type wrapper TieringCostRehydrationInfo + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TieringCostRehydrationInfo: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TieringCostRehydrationInfo: %+v", err) + } + + decoded["objectType"] = "TieringCostRehydrationInfo" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TieringCostRehydrationInfo: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostsavinginfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostsavinginfo.go new file mode 100644 index 00000000000..e9b5dbd5fc3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/model_tieringcostsavinginfo.go @@ -0,0 +1,53 @@ +package fetchtieringcost + +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 _ TieringCostInfo = TieringCostSavingInfo{} + +type TieringCostSavingInfo struct { + RetailSourceTierCostPerGBPerMonth float64 `json:"retailSourceTierCostPerGBPerMonth"` + RetailTargetTierCostPerGBPerMonth float64 `json:"retailTargetTierCostPerGBPerMonth"` + SourceTierSizeReductionInBytes int64 `json:"sourceTierSizeReductionInBytes"` + TargetTierSizeIncreaseInBytes int64 `json:"targetTierSizeIncreaseInBytes"` + + // Fields inherited from TieringCostInfo + + ObjectType string `json:"objectType"` +} + +func (s TieringCostSavingInfo) TieringCostInfo() BaseTieringCostInfoImpl { + return BaseTieringCostInfoImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = TieringCostSavingInfo{} + +func (s TieringCostSavingInfo) MarshalJSON() ([]byte, error) { + type wrapper TieringCostSavingInfo + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TieringCostSavingInfo: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TieringCostSavingInfo: %+v", err) + } + + decoded["objectType"] = "TieringCostSavingInfo" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TieringCostSavingInfo: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/version.go new file mode 100644 index 00000000000..4e22f4e4356 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/fetchtieringcost/version.go @@ -0,0 +1,10 @@ +package fetchtieringcost + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/fetchtieringcost/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/README.md new file mode 100644 index 00000000000..dadbd5a95bc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/README.md @@ -0,0 +1,57 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections` Documentation + +The `itemlevelrecoveryconnections` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/itemlevelrecoveryconnections" +``` + + +### Client Initialization + +```go +client := itemlevelrecoveryconnections.NewItemLevelRecoveryConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ItemLevelRecoveryConnectionsClient.Provision` + +```go +ctx := context.TODO() +id := itemlevelrecoveryconnections.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + +payload := itemlevelrecoveryconnections.ILRRequestResource{ + // ... +} + + +read, err := client.Provision(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ItemLevelRecoveryConnectionsClient.Revoke` + +```go +ctx := context.TODO() +id := itemlevelrecoveryconnections.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + +read, err := client.Revoke(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/client.go new file mode 100644 index 00000000000..9dc4e42e08b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/client.go @@ -0,0 +1,18 @@ +package itemlevelrecoveryconnections + +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 ItemLevelRecoveryConnectionsClient struct { + Client autorest.Client + baseUri string +} + +func NewItemLevelRecoveryConnectionsClientWithBaseURI(endpoint string) ItemLevelRecoveryConnectionsClient { + return ItemLevelRecoveryConnectionsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/id_recoverypoint.go new file mode 100644 index 00000000000..603b7af1848 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/id_recoverypoint.go @@ -0,0 +1,166 @@ +package itemlevelrecoveryconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(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 := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemName"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointId"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) 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), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/id_recoverypoint_test.go new file mode 100644 index 00000000000..c7c6bf018c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package itemlevelrecoveryconnections + +import ( + "testing" + + "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 = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } + + if id.ProtectedItemName != "protectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemName") + } + + if id.RecoveryPointId != "recoveryPointId" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointId") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + RecoveryPointId: "recoveryPointId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + RecoveryPointId: "recoveryPointId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS/rEcOvErYpOiNtId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + ProtectedItemName: "pRoTeCtEdItEmNaMe", + RecoveryPointId: "rEcOvErYpOiNtId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS/rEcOvErYpOiNtId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/method_provision_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/method_provision_autorest.go new file mode 100644 index 00000000000..9d96e89f2fd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/method_provision_autorest.go @@ -0,0 +1,68 @@ +package itemlevelrecoveryconnections + +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 ProvisionOperationResponse struct { + HttpResponse *http.Response +} + +// Provision ... +func (c ItemLevelRecoveryConnectionsClient) Provision(ctx context.Context, id RecoveryPointId, input ILRRequestResource) (result ProvisionOperationResponse, err error) { + req, err := c.preparerForProvision(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Provision", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Provision", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForProvision(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Provision", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForProvision prepares the Provision request. +func (c ItemLevelRecoveryConnectionsClient) preparerForProvision(ctx context.Context, id RecoveryPointId, input ILRRequestResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/provisionInstantItemRecovery", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForProvision handles the response to the Provision request. The method always +// closes the http.Response Body. +func (c ItemLevelRecoveryConnectionsClient) responderForProvision(resp *http.Response) (result ProvisionOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/method_revoke_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/method_revoke_autorest.go new file mode 100644 index 00000000000..9ea351e638d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/method_revoke_autorest.go @@ -0,0 +1,67 @@ +package itemlevelrecoveryconnections + +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 RevokeOperationResponse struct { + HttpResponse *http.Response +} + +// Revoke ... +func (c ItemLevelRecoveryConnectionsClient) Revoke(ctx context.Context, id RecoveryPointId) (result RevokeOperationResponse, err error) { + req, err := c.preparerForRevoke(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Revoke", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Revoke", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRevoke(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Revoke", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRevoke prepares the Revoke request. +func (c ItemLevelRecoveryConnectionsClient) preparerForRevoke(ctx context.Context, id RecoveryPointId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/revokeInstantItemRecovery", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRevoke handles the response to the Revoke request. The method always +// closes the http.Response Body. +func (c ItemLevelRecoveryConnectionsClient) responderForRevoke(resp *http.Response) (result RevokeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go new file mode 100644 index 00000000000..51a2357a9dc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go @@ -0,0 +1,51 @@ +package itemlevelrecoveryconnections + +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 _ ILRRequest = AzureFileShareProvisionILRRequest{} + +type AzureFileShareProvisionILRRequest struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + + // Fields inherited from ILRRequest + + ObjectType string `json:"objectType"` +} + +func (s AzureFileShareProvisionILRRequest) ILRRequest() BaseILRRequestImpl { + return BaseILRRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureFileShareProvisionILRRequest{} + +func (s AzureFileShareProvisionILRRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProvisionILRRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProvisionILRRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProvisionILRRequest: %+v", err) + } + + decoded["objectType"] = "AzureFileShareProvisionILRRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProvisionILRRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go new file mode 100644 index 00000000000..c2ac088fea6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go @@ -0,0 +1,53 @@ +package itemlevelrecoveryconnections + +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 _ ILRRequest = IaasVMILRRegistrationRequest{} + +type IaasVMILRRegistrationRequest struct { + InitiatorName *string `json:"initiatorName,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RenewExistingRegistration *bool `json:"renewExistingRegistration,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ILRRequest + + ObjectType string `json:"objectType"` +} + +func (s IaasVMILRRegistrationRequest) ILRRequest() BaseILRRequestImpl { + return BaseILRRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = IaasVMILRRegistrationRequest{} + +func (s IaasVMILRRegistrationRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMILRRegistrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMILRRegistrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMILRRegistrationRequest: %+v", err) + } + + decoded["objectType"] = "IaasVMILRRegistrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMILRRegistrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_ilrrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_ilrrequest.go new file mode 100644 index 00000000000..5874d766537 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_ilrrequest.go @@ -0,0 +1,83 @@ +package itemlevelrecoveryconnections + +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 ILRRequest interface { + ILRRequest() BaseILRRequestImpl +} + +var _ ILRRequest = BaseILRRequestImpl{} + +type BaseILRRequestImpl struct { + ObjectType string `json:"objectType"` +} + +func (s BaseILRRequestImpl) ILRRequest() BaseILRRequestImpl { + return s +} + +var _ ILRRequest = RawILRRequestImpl{} + +// RawILRRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawILRRequestImpl struct { + iLRRequest BaseILRRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawILRRequestImpl) ILRRequest() BaseILRRequestImpl { + return s.iLRRequest +} + +func UnmarshalILRRequestImplementation(input []byte) (ILRRequest, 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 ILRRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureFileShareProvisionILRRequest") { + var out AzureFileShareProvisionILRRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProvisionILRRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMILRRegistrationRequest") { + var out IaasVMILRRegistrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMILRRegistrationRequest: %+v", err) + } + return out, nil + } + + var parent BaseILRRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseILRRequestImpl: %+v", err) + } + + return RawILRRequestImpl{ + iLRRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_ilrrequestresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_ilrrequestresource.go new file mode 100644 index 00000000000..78a909a753c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/model_ilrrequestresource.go @@ -0,0 +1,57 @@ +package itemlevelrecoveryconnections + +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 ILRRequestResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ILRRequest `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ILRRequestResource{} + +func (s *ILRRequestResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 ILRRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalILRRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ILRRequestResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/version.go new file mode 100644 index 00000000000..cbf686f8625 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/itemlevelrecoveryconnections/version.go @@ -0,0 +1,10 @@ +package itemlevelrecoveryconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/itemlevelrecoveryconnections/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/client.go new file mode 100644 index 00000000000..00a3fc2ea01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/client.go @@ -0,0 +1,18 @@ +package jobcancellations + +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 JobCancellationsClient struct { + Client autorest.Client + baseUri string +} + +func NewJobCancellationsClientWithBaseURI(endpoint string) JobCancellationsClient { + return JobCancellationsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/id_backupjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/id_backupjob.go new file mode 100644 index 00000000000..fda0835fc5f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/id_backupjob.go @@ -0,0 +1,139 @@ +package jobcancellations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupJobId{}) +} + +var _ resourceids.ResourceId = &BackupJobId{} + +// BackupJobId is a struct representing the Resource ID for a Backup Job +type BackupJobId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupJobName string +} + +// NewBackupJobID returns a new BackupJobId struct +func NewBackupJobID(subscriptionId string, resourceGroupName string, vaultName string, backupJobName string) BackupJobId { + return BackupJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupJobName: backupJobName, + } +} + +// ParseBackupJobID parses 'input' into a BackupJobId +func ParseBackupJobID(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupJobIDInsensitively parses 'input' case-insensitively into a BackupJobId +// note: this method should only be used for API response data and not user input +func ParseBackupJobIDInsensitively(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupJobName, ok = input.Parsed["backupJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupJobName", input) + } + + return nil +} + +// ValidateBackupJobID checks that 'input' can be parsed as a Backup Job ID +func ValidateBackupJobID(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 := ParseBackupJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Job ID +func (id BackupJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Job ID +func (id BackupJobId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupJobs", "backupJobs", "backupJobs"), + resourceids.UserSpecifiedSegment("backupJobName", "backupJobName"), + } +} + +// String returns a human-readable description of this Backup Job ID +func (id BackupJobId) 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 Job Name: %q", id.BackupJobName), + } + return fmt.Sprintf("Backup Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/id_backupjob_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/id_backupjob_test.go new file mode 100644 index 00000000000..dc12aed1885 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/id_backupjob_test.go @@ -0,0 +1,327 @@ +package jobcancellations + +import ( + "testing" + + "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 = &BackupJobId{} + +func TestNewBackupJobID(t *testing.T) { + id := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupJobName != "backupJobName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupJobName'", id.BackupJobName, "backupJobName") + } +} + +func TestFormatBackupJobID(t *testing.T) { + actual := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupJobName: "backupJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupJobName != v.Expected.BackupJobName { + t.Fatalf("Expected %q but got %q for BackupJobName", v.Expected.BackupJobName, actual.BackupJobName) + } + + } +} + +func TestParseBackupJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupJobName: "backupJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPjObS/bAcKuPjObNaMe", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupJobName: "bAcKuPjObNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPjObS/bAcKuPjObNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupJobName != v.Expected.BackupJobName { + t.Fatalf("Expected %q but got %q for BackupJobName", v.Expected.BackupJobName, actual.BackupJobName) + } + + } +} + +func TestSegmentsForBackupJobId(t *testing.T) { + segments := BackupJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/method_trigger_autorest.go new file mode 100644 index 00000000000..9159d1476cb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/method_trigger_autorest.go @@ -0,0 +1,67 @@ +package jobcancellations + +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 TriggerOperationResponse struct { + HttpResponse *http.Response +} + +// Trigger ... +func (c JobCancellationsClient) Trigger(ctx context.Context, id BackupJobId) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "jobcancellations.JobCancellationsClient", "Trigger", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "jobcancellations.JobCancellationsClient", "Trigger", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTrigger(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "jobcancellations.JobCancellationsClient", "Trigger", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTrigger prepares the Trigger request. +func (c JobCancellationsClient) preparerForTrigger(ctx context.Context, id BackupJobId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/cancel", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTrigger handles the response to the Trigger request. The method always +// closes the http.Response Body. +func (c JobCancellationsClient) responderForTrigger(resp *http.Response) (result TriggerOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/version.go new file mode 100644 index 00000000000..f282d7470a9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobcancellations/version.go @@ -0,0 +1,10 @@ +package jobcancellations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/jobcancellations/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/README.md new file mode 100644 index 00000000000..185fad08903 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails` Documentation + +The `jobdetails` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/jobdetails" +``` + + +### Client Initialization + +```go +client := jobdetails.NewJobDetailsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `JobDetailsClient.Get` + +```go +ctx := context.TODO() +id := jobdetails.NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupJobName") + +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/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/client.go new file mode 100644 index 00000000000..465d9e82eba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/client.go @@ -0,0 +1,18 @@ +package jobdetails + +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 JobDetailsClient struct { + Client autorest.Client + baseUri string +} + +func NewJobDetailsClientWithBaseURI(endpoint string) JobDetailsClient { + return JobDetailsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/constants.go new file mode 100644 index 00000000000..6a4f8d85320 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/constants.go @@ -0,0 +1,225 @@ +package jobdetails + +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 JobSupportedAction string + +const ( + JobSupportedActionCancellable JobSupportedAction = "Cancellable" + JobSupportedActionInvalid JobSupportedAction = "Invalid" + JobSupportedActionRetriable JobSupportedAction = "Retriable" +) + +func PossibleValuesForJobSupportedAction() []string { + return []string{ + string(JobSupportedActionCancellable), + string(JobSupportedActionInvalid), + string(JobSupportedActionRetriable), + } +} + +func parseJobSupportedAction(input string) (*JobSupportedAction, error) { + vals := map[string]JobSupportedAction{ + "cancellable": JobSupportedActionCancellable, + "invalid": JobSupportedActionInvalid, + "retriable": JobSupportedActionRetriable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobSupportedAction(input) + return &out, nil +} + +type MabServerType string + +const ( + MabServerTypeAzureBackupServerContainer MabServerType = "AzureBackupServerContainer" + MabServerTypeAzureSqlContainer MabServerType = "AzureSqlContainer" + MabServerTypeCluster MabServerType = "Cluster" + MabServerTypeDPMContainer MabServerType = "DPMContainer" + MabServerTypeGenericContainer MabServerType = "GenericContainer" + MabServerTypeIaasVMContainer MabServerType = "IaasVMContainer" + MabServerTypeIaasVMServiceContainer MabServerType = "IaasVMServiceContainer" + MabServerTypeInvalid MabServerType = "Invalid" + MabServerTypeMABContainer MabServerType = "MABContainer" + MabServerTypeSQLAGWorkLoadContainer MabServerType = "SQLAGWorkLoadContainer" + MabServerTypeStorageContainer MabServerType = "StorageContainer" + MabServerTypeUnknown MabServerType = "Unknown" + MabServerTypeVCenter MabServerType = "VCenter" + MabServerTypeVMAppContainer MabServerType = "VMAppContainer" + MabServerTypeWindows MabServerType = "Windows" +) + +func PossibleValuesForMabServerType() []string { + return []string{ + string(MabServerTypeAzureBackupServerContainer), + string(MabServerTypeAzureSqlContainer), + string(MabServerTypeCluster), + string(MabServerTypeDPMContainer), + string(MabServerTypeGenericContainer), + string(MabServerTypeIaasVMContainer), + string(MabServerTypeIaasVMServiceContainer), + string(MabServerTypeInvalid), + string(MabServerTypeMABContainer), + string(MabServerTypeSQLAGWorkLoadContainer), + string(MabServerTypeStorageContainer), + string(MabServerTypeUnknown), + string(MabServerTypeVCenter), + string(MabServerTypeVMAppContainer), + string(MabServerTypeWindows), + } +} + +func parseMabServerType(input string) (*MabServerType, error) { + vals := map[string]MabServerType{ + "azurebackupservercontainer": MabServerTypeAzureBackupServerContainer, + "azuresqlcontainer": MabServerTypeAzureSqlContainer, + "cluster": MabServerTypeCluster, + "dpmcontainer": MabServerTypeDPMContainer, + "genericcontainer": MabServerTypeGenericContainer, + "iaasvmcontainer": MabServerTypeIaasVMContainer, + "iaasvmservicecontainer": MabServerTypeIaasVMServiceContainer, + "invalid": MabServerTypeInvalid, + "mabcontainer": MabServerTypeMABContainer, + "sqlagworkloadcontainer": MabServerTypeSQLAGWorkLoadContainer, + "storagecontainer": MabServerTypeStorageContainer, + "unknown": MabServerTypeUnknown, + "vcenter": MabServerTypeVCenter, + "vmappcontainer": MabServerTypeVMAppContainer, + "windows": MabServerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MabServerType(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" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + 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(WorkloadTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "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/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/id_backupjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/id_backupjob.go new file mode 100644 index 00000000000..68dd9a83910 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/id_backupjob.go @@ -0,0 +1,139 @@ +package jobdetails + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupJobId{}) +} + +var _ resourceids.ResourceId = &BackupJobId{} + +// BackupJobId is a struct representing the Resource ID for a Backup Job +type BackupJobId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupJobName string +} + +// NewBackupJobID returns a new BackupJobId struct +func NewBackupJobID(subscriptionId string, resourceGroupName string, vaultName string, backupJobName string) BackupJobId { + return BackupJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupJobName: backupJobName, + } +} + +// ParseBackupJobID parses 'input' into a BackupJobId +func ParseBackupJobID(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupJobIDInsensitively parses 'input' case-insensitively into a BackupJobId +// note: this method should only be used for API response data and not user input +func ParseBackupJobIDInsensitively(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupJobName, ok = input.Parsed["backupJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupJobName", input) + } + + return nil +} + +// ValidateBackupJobID checks that 'input' can be parsed as a Backup Job ID +func ValidateBackupJobID(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 := ParseBackupJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Job ID +func (id BackupJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Job ID +func (id BackupJobId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupJobs", "backupJobs", "backupJobs"), + resourceids.UserSpecifiedSegment("backupJobName", "backupJobName"), + } +} + +// String returns a human-readable description of this Backup Job ID +func (id BackupJobId) 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 Job Name: %q", id.BackupJobName), + } + return fmt.Sprintf("Backup Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/id_backupjob_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/id_backupjob_test.go new file mode 100644 index 00000000000..7623e595a78 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/id_backupjob_test.go @@ -0,0 +1,327 @@ +package jobdetails + +import ( + "testing" + + "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 = &BackupJobId{} + +func TestNewBackupJobID(t *testing.T) { + id := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupJobName != "backupJobName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupJobName'", id.BackupJobName, "backupJobName") + } +} + +func TestFormatBackupJobID(t *testing.T) { + actual := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupJobName: "backupJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupJobName != v.Expected.BackupJobName { + t.Fatalf("Expected %q but got %q for BackupJobName", v.Expected.BackupJobName, actual.BackupJobName) + } + + } +} + +func TestParseBackupJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupJobName: "backupJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupJobs/backupJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPjObS/bAcKuPjObNaMe", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupJobName: "bAcKuPjObNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPjObS/bAcKuPjObNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupJobName != v.Expected.BackupJobName { + t.Fatalf("Expected %q but got %q for BackupJobName", v.Expected.BackupJobName, actual.BackupJobName) + } + + } +} + +func TestSegmentsForBackupJobId(t *testing.T) { + segments := BackupJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/method_get_autorest.go new file mode 100644 index 00000000000..aa3589e2635 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/method_get_autorest.go @@ -0,0 +1,68 @@ +package jobdetails + +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 *JobResource +} + +// Get ... +func (c JobDetailsClient) Get(ctx context.Context, id BackupJobId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "jobdetails.JobDetailsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "jobdetails.JobDetailsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "jobdetails.JobDetailsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c JobDetailsClient) preparerForGet(ctx context.Context, id BackupJobId) (*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 JobDetailsClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmerrorinfo.go new file mode 100644 index 00000000000..47de469765b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmerrorinfo.go @@ -0,0 +1,11 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + ErrorTitle *string `json:"errorTitle,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjob.go new file mode 100644 index 00000000000..36c6e9749fe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjob.go @@ -0,0 +1,97 @@ +package jobdetails + +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 _ Job = AzureIaaSVMJob{} + +type AzureIaaSVMJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureIaaSVMErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureIaaSVMJobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered *bool `json:"isUserTriggered,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s AzureIaaSVMJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *AzureIaaSVMJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureIaaSVMJob{} + +func (s AzureIaaSVMJob) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMJob: %+v", err) + } + + decoded["jobType"] = "AzureIaaSVMJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobextendedinfo.go new file mode 100644 index 00000000000..4dba88ce53a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobextendedinfo.go @@ -0,0 +1,13 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + EstimatedRemainingDuration *string `json:"estimatedRemainingDuration,omitempty"` + InternalPropertyBag *map[string]string `json:"internalPropertyBag,omitempty"` + ProgressPercentage *float64 `json:"progressPercentage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureIaaSVMJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobtaskdetails.go new file mode 100644 index 00000000000..ae1cc624792 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobtaskdetails.go @@ -0,0 +1,45 @@ +package jobdetails + +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 AzureIaaSVMJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + InstanceId *string `json:"instanceId,omitempty"` + ProgressPercentage *float64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskExecutionDetails *string `json:"taskExecutionDetails,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *AzureIaaSVMJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobv2.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobv2.go new file mode 100644 index 00000000000..b895bf10247 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureiaasvmjobv2.go @@ -0,0 +1,96 @@ +package jobdetails + +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 _ Job = AzureIaaSVMJobV2{} + +type AzureIaaSVMJobV2 struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureIaaSVMErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureIaaSVMJobExtendedInfo `json:"extendedInfo,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s AzureIaaSVMJobV2) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *AzureIaaSVMJobV2) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobV2) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJobV2) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobV2) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureIaaSVMJobV2{} + +func (s AzureIaaSVMJobV2) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMJobV2 + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMJobV2: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMJobV2: %+v", err) + } + + decoded["jobType"] = "AzureIaaSVMJobV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMJobV2: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestorageerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestorageerrorinfo.go new file mode 100644 index 00000000000..28cf64eae5f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestorageerrorinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejob.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejob.go new file mode 100644 index 00000000000..6ca72a178a9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejob.go @@ -0,0 +1,97 @@ +package jobdetails + +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 _ Job = AzureStorageJob{} + +type AzureStorageJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureStorageErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureStorageJobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered *bool `json:"isUserTriggered,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s AzureStorageJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *AzureStorageJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureStorageJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureStorageJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureStorageJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureStorageJob{} + +func (s AzureStorageJob) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageJob: %+v", err) + } + + decoded["jobType"] = "AzureStorageJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejobextendedinfo.go new file mode 100644 index 00000000000..b687b944e42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejobextendedinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureStorageJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejobtaskdetails.go new file mode 100644 index 00000000000..9cc5cb916c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azurestoragejobtaskdetails.go @@ -0,0 +1,9 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageJobTaskDetails struct { + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloaderrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloaderrorinfo.go new file mode 100644 index 00000000000..d54f4b2217f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloaderrorinfo.go @@ -0,0 +1,12 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadErrorInfo struct { + AdditionalDetails *string `json:"additionalDetails,omitempty"` + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + ErrorTitle *string `json:"errorTitle,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjob.go new file mode 100644 index 00000000000..3626ba712ab --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjob.go @@ -0,0 +1,95 @@ +package jobdetails + +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 _ Job = AzureWorkloadJob{} + +type AzureWorkloadJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureWorkloadErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureWorkloadJobExtendedInfo `json:"extendedInfo,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s AzureWorkloadJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *AzureWorkloadJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureWorkloadJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureWorkloadJob{} + +func (s AzureWorkloadJob) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadJob: %+v", err) + } + + decoded["jobType"] = "AzureWorkloadJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjobextendedinfo.go new file mode 100644 index 00000000000..b086f0ffee5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjobextendedinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureWorkloadJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjobtaskdetails.go new file mode 100644 index 00000000000..b6d9349f0c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_azureworkloadjobtaskdetails.go @@ -0,0 +1,9 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadJobTaskDetails struct { + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmerrorinfo.go new file mode 100644 index 00000000000..987eb3a7bcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmerrorinfo.go @@ -0,0 +1,9 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmErrorInfo struct { + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjob.go new file mode 100644 index 00000000000..f4c21101cf0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjob.go @@ -0,0 +1,98 @@ +package jobdetails + +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 _ Job = DpmJob{} + +type DpmJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + ContainerType *string `json:"containerType,omitempty"` + DpmServerName *string `json:"dpmServerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]DpmErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *DpmJobExtendedInfo `json:"extendedInfo,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s DpmJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *DpmJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DpmJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = DpmJob{} + +func (s DpmJob) MarshalJSON() ([]byte, error) { + type wrapper DpmJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmJob: %+v", err) + } + + decoded["jobType"] = "DpmJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjobextendedinfo.go new file mode 100644 index 00000000000..e06f6f2aa5e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjobextendedinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]DpmJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjobtaskdetails.go new file mode 100644 index 00000000000..9b8583d9233 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_dpmjobtaskdetails.go @@ -0,0 +1,42 @@ +package jobdetails + +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 DpmJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *DpmJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DpmJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_job.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_job.go new file mode 100644 index 00000000000..c777a204586 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_job.go @@ -0,0 +1,130 @@ +package jobdetails + +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 Job interface { + Job() BaseJobImpl +} + +var _ Job = BaseJobImpl{} + +type BaseJobImpl struct { + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s BaseJobImpl) Job() BaseJobImpl { + return s +} + +var _ Job = RawJobImpl{} + +// RawJobImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawJobImpl struct { + job BaseJobImpl + Type string + Values map[string]interface{} +} + +func (s RawJobImpl) Job() BaseJobImpl { + return s.job +} + +func UnmarshalJobImplementation(input []byte) (Job, 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 Job into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureIaaSVMJob") { + var out AzureIaaSVMJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMJobV2") { + var out AzureIaaSVMJobV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMJobV2: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureStorageJob") { + var out AzureStorageJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadJob") { + var out AzureWorkloadJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DpmJob") { + var out DpmJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MabJob") { + var out MabJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VaultJob") { + var out VaultJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VaultJob: %+v", err) + } + return out, nil + } + + var parent BaseJobImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobImpl: %+v", err) + } + + return RawJobImpl{ + job: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_jobresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_jobresource.go new file mode 100644 index 00000000000..8019865441e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_jobresource.go @@ -0,0 +1,57 @@ +package jobdetails + +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 JobResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties Job `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &JobResource{} + +func (s *JobResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 JobResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalJobImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'JobResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_maberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_maberrorinfo.go new file mode 100644 index 00000000000..d12afd9a026 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_maberrorinfo.go @@ -0,0 +1,9 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabErrorInfo struct { + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjob.go new file mode 100644 index 00000000000..8e1355cf4bc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjob.go @@ -0,0 +1,97 @@ +package jobdetails + +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 _ Job = MabJob{} + +type MabJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]MabErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *MabJobExtendedInfo `json:"extendedInfo,omitempty"` + MabServerName *string `json:"mabServerName,omitempty"` + MabServerType *MabServerType `json:"mabServerType,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s MabJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *MabJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MabJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = MabJob{} + +func (s MabJob) MarshalJSON() ([]byte, error) { + type wrapper MabJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabJob: %+v", err) + } + + decoded["jobType"] = "MabJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjobextendedinfo.go new file mode 100644 index 00000000000..b08829e160a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjobextendedinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]MabJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjobtaskdetails.go new file mode 100644 index 00000000000..c923d5d3282 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_mabjobtaskdetails.go @@ -0,0 +1,42 @@ +package jobdetails + +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 MabJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *MabJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MabJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjob.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjob.go new file mode 100644 index 00000000000..c9d2e1b953f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjob.go @@ -0,0 +1,94 @@ +package jobdetails + +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 _ Job = VaultJob{} + +type VaultJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]VaultJobErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *VaultJobExtendedInfo `json:"extendedInfo,omitempty"` + + // Fields inherited from Job + + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + JobType string `json:"jobType"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (s VaultJob) Job() BaseJobImpl { + return BaseJobImpl{ + ActivityId: s.ActivityId, + BackupManagementType: s.BackupManagementType, + EndTime: s.EndTime, + EntityFriendlyName: s.EntityFriendlyName, + JobType: s.JobType, + Operation: s.Operation, + StartTime: s.StartTime, + Status: s.Status, + } +} + +func (o *VaultJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *VaultJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = VaultJob{} + +func (s VaultJob) MarshalJSON() ([]byte, error) { + type wrapper VaultJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VaultJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VaultJob: %+v", err) + } + + decoded["jobType"] = "VaultJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VaultJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjoberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjoberrorinfo.go new file mode 100644 index 00000000000..8369add63df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjoberrorinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultJobErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjobextendedinfo.go new file mode 100644 index 00000000000..78248901487 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/model_vaultjobextendedinfo.go @@ -0,0 +1,8 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultJobExtendedInfo struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/version.go new file mode 100644 index 00000000000..6fd17a7c93f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobdetails/version.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/jobdetails/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobs/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/client.go new file mode 100644 index 00000000000..fd4e7899bb5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/client.go @@ -0,0 +1,18 @@ +package jobs + +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 JobsClient struct { + Client autorest.Client + baseUri string +} + +func NewJobsClientWithBaseURI(endpoint string) JobsClient { + return JobsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/id_vault.go new file mode 100644 index 00000000000..eaa508afacb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/id_vault.go @@ -0,0 +1,130 @@ +package jobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/jobs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/id_vault_test.go new file mode 100644 index 00000000000..553cd05b262 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/id_vault_test.go @@ -0,0 +1,282 @@ +package jobs + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobs/method_export_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/method_export_autorest.go new file mode 100644 index 00000000000..d6662857fa9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/method_export_autorest.go @@ -0,0 +1,96 @@ +package jobs + +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 ExportOperationResponse struct { + HttpResponse *http.Response +} + +type ExportOperationOptions struct { + Filter *string +} + +func DefaultExportOperationOptions() ExportOperationOptions { + return ExportOperationOptions{} +} + +func (o ExportOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ExportOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Export ... +func (c JobsClient) Export(ctx context.Context, id VaultId, options ExportOperationOptions) (result ExportOperationResponse, err error) { + req, err := c.preparerForExport(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "jobs.JobsClient", "Export", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "jobs.JobsClient", "Export", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForExport(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "jobs.JobsClient", "Export", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForExport prepares the Export request. +func (c JobsClient) preparerForExport(ctx context.Context, id VaultId, options ExportOperationOptions) (*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/backupJobsExport", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForExport handles the response to the Export request. The method always +// closes the http.Response Body. +func (c JobsClient) responderForExport(resp *http.Response) (result ExportOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/jobs/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/version.go new file mode 100644 index 00000000000..e66abaa44f1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/jobs/version.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/jobs/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/operation/README.md new file mode 100644 index 00000000000..24eb761fbd9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/operation` Documentation + +The `operation` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/operation" +``` + + +### Client Initialization + +```go +client := operation.NewOperationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OperationClient.Validate` + +```go +ctx := context.TODO() +id := operation.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := operation.ValidateOperationRequestResource{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/client.go new file mode 100644 index 00000000000..3a57d0e0d4c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/client.go @@ -0,0 +1,18 @@ +package operation + +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 OperationClient struct { + Client autorest.Client + baseUri string +} + +func NewOperationClientWithBaseURI(endpoint string) OperationClient { + return OperationClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/constants.go new file mode 100644 index 00000000000..23a685aa283 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/constants.go @@ -0,0 +1,274 @@ +package operation + +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 CopyOptions string + +const ( + CopyOptionsCreateCopy CopyOptions = "CreateCopy" + CopyOptionsFailOnConflict CopyOptions = "FailOnConflict" + CopyOptionsInvalid CopyOptions = "Invalid" + CopyOptionsOverwrite CopyOptions = "Overwrite" + CopyOptionsSkip CopyOptions = "Skip" +) + +func PossibleValuesForCopyOptions() []string { + return []string{ + string(CopyOptionsCreateCopy), + string(CopyOptionsFailOnConflict), + string(CopyOptionsInvalid), + string(CopyOptionsOverwrite), + string(CopyOptionsSkip), + } +} + +func parseCopyOptions(input string) (*CopyOptions, error) { + vals := map[string]CopyOptions{ + "createcopy": CopyOptionsCreateCopy, + "failonconflict": CopyOptionsFailOnConflict, + "invalid": CopyOptionsInvalid, + "overwrite": CopyOptionsOverwrite, + "skip": CopyOptionsSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CopyOptions(input) + return &out, nil +} + +type OverwriteOptions string + +const ( + OverwriteOptionsFailOnConflict OverwriteOptions = "FailOnConflict" + OverwriteOptionsInvalid OverwriteOptions = "Invalid" + OverwriteOptionsOverwrite OverwriteOptions = "Overwrite" +) + +func PossibleValuesForOverwriteOptions() []string { + return []string{ + string(OverwriteOptionsFailOnConflict), + string(OverwriteOptionsInvalid), + string(OverwriteOptionsOverwrite), + } +} + +func parseOverwriteOptions(input string) (*OverwriteOptions, error) { + vals := map[string]OverwriteOptions{ + "failonconflict": OverwriteOptionsFailOnConflict, + "invalid": OverwriteOptionsInvalid, + "overwrite": OverwriteOptionsOverwrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverwriteOptions(input) + return &out, nil +} + +type RecoveryMode string + +const ( + RecoveryModeFileRecovery RecoveryMode = "FileRecovery" + RecoveryModeInvalid RecoveryMode = "Invalid" + RecoveryModeRecoveryUsingSnapshot RecoveryMode = "RecoveryUsingSnapshot" + RecoveryModeSnapshotAttach RecoveryMode = "SnapshotAttach" + RecoveryModeSnapshotAttachAndRecover RecoveryMode = "SnapshotAttachAndRecover" + RecoveryModeWorkloadRecovery RecoveryMode = "WorkloadRecovery" +) + +func PossibleValuesForRecoveryMode() []string { + return []string{ + string(RecoveryModeFileRecovery), + string(RecoveryModeInvalid), + string(RecoveryModeRecoveryUsingSnapshot), + string(RecoveryModeSnapshotAttach), + string(RecoveryModeSnapshotAttachAndRecover), + string(RecoveryModeWorkloadRecovery), + } +} + +func parseRecoveryMode(input string) (*RecoveryMode, error) { + vals := map[string]RecoveryMode{ + "filerecovery": RecoveryModeFileRecovery, + "invalid": RecoveryModeInvalid, + "recoveryusingsnapshot": RecoveryModeRecoveryUsingSnapshot, + "snapshotattach": RecoveryModeSnapshotAttach, + "snapshotattachandrecover": RecoveryModeSnapshotAttachAndRecover, + "workloadrecovery": RecoveryModeWorkloadRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryMode(input) + return &out, nil +} + +type RecoveryType string + +const ( + RecoveryTypeAlternateLocation RecoveryType = "AlternateLocation" + RecoveryTypeInvalid RecoveryType = "Invalid" + RecoveryTypeOffline RecoveryType = "Offline" + RecoveryTypeOriginalLocation RecoveryType = "OriginalLocation" + RecoveryTypeRestoreDisks RecoveryType = "RestoreDisks" +) + +func PossibleValuesForRecoveryType() []string { + return []string{ + string(RecoveryTypeAlternateLocation), + string(RecoveryTypeInvalid), + string(RecoveryTypeOffline), + string(RecoveryTypeOriginalLocation), + string(RecoveryTypeRestoreDisks), + } +} + +func parseRecoveryType(input string) (*RecoveryType, error) { + vals := map[string]RecoveryType{ + "alternatelocation": RecoveryTypeAlternateLocation, + "invalid": RecoveryTypeInvalid, + "offline": RecoveryTypeOffline, + "originallocation": RecoveryTypeOriginalLocation, + "restoredisks": RecoveryTypeRestoreDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryType(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityStandard), + } +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} + +type RestoreRequestType string + +const ( + RestoreRequestTypeFullShareRestore RestoreRequestType = "FullShareRestore" + RestoreRequestTypeInvalid RestoreRequestType = "Invalid" + RestoreRequestTypeItemLevelRestore RestoreRequestType = "ItemLevelRestore" +) + +func PossibleValuesForRestoreRequestType() []string { + return []string{ + string(RestoreRequestTypeFullShareRestore), + string(RestoreRequestTypeInvalid), + string(RestoreRequestTypeItemLevelRestore), + } +} + +func parseRestoreRequestType(input string) (*RestoreRequestType, error) { + vals := map[string]RestoreRequestType{ + "fullsharerestore": RestoreRequestTypeFullShareRestore, + "invalid": RestoreRequestTypeInvalid, + "itemlevelrestore": RestoreRequestTypeItemLevelRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreRequestType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} + +type TargetDiskNetworkAccessOption string + +const ( + TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePrivateAccessForAllDisks" + TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePublicAccessForAllDisks" + TargetDiskNetworkAccessOptionSameAsOnSourceDisks TargetDiskNetworkAccessOption = "SameAsOnSourceDisks" +) + +func PossibleValuesForTargetDiskNetworkAccessOption() []string { + return []string{ + string(TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks), + string(TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks), + string(TargetDiskNetworkAccessOptionSameAsOnSourceDisks), + } +} + +func parseTargetDiskNetworkAccessOption(input string) (*TargetDiskNetworkAccessOption, error) { + vals := map[string]TargetDiskNetworkAccessOption{ + "enableprivateaccessforalldisks": TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks, + "enablepublicaccessforalldisks": TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks, + "sameasonsourcedisks": TargetDiskNetworkAccessOptionSameAsOnSourceDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetDiskNetworkAccessOption(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/id_vault.go new file mode 100644 index 00000000000..05d054e5c41 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/id_vault.go @@ -0,0 +1,130 @@ +package operation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/operation/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/id_vault_test.go new file mode 100644 index 00000000000..a6ba4e3a2c7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/id_vault_test.go @@ -0,0 +1,282 @@ +package operation + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/method_validate_autorest.go new file mode 100644 index 00000000000..05bac629ddd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/method_validate_autorest.go @@ -0,0 +1,70 @@ +package operation + +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 ValidateOperationApiResponse struct { + HttpResponse *http.Response + Model *ValidateOperationsResponse +} + +// Validate ... +func (c OperationClient) Validate(ctx context.Context, id VaultId, input ValidateOperationRequestResource) (result ValidateOperationApiResponse, err error) { + req, err := c.preparerForValidate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "operation.OperationClient", "Validate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operation.OperationClient", "Validate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForValidate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operation.OperationClient", "Validate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForValidate prepares the Validate request. +func (c OperationClient) preparerForValidate(ctx context.Context, id VaultId, input ValidateOperationRequestResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupValidateOperation", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForValidate handles the response to the Validate request. The method always +// closes the http.Response Body. +func (c OperationClient) responderForValidate(resp *http.Response) (result ValidateOperationApiResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..db4906bc43b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azurefilesharerestorerequest.go @@ -0,0 +1,57 @@ +package operation + +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 _ RestoreRequest = AzureFileShareRestoreRequest{} + +type AzureFileShareRestoreRequest struct { + CopyOptions *CopyOptions `json:"copyOptions,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + RestoreFileSpecs *[]RestoreFileSpecs `json:"restoreFileSpecs,omitempty"` + RestoreRequestType *RestoreRequestType `json:"restoreRequestType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetDetails *TargetAFSRestoreInfo `json:"targetDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureFileShareRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureFileShareRestoreRequest{} + +func (s AzureFileShareRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureFileShareRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..151dbed826b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,61 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadPointInTimeRestoreRequest{} + +type AzureWorkloadPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRestoreRequest{} + +func (s AzureWorkloadPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..5fe55046185 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadrestorerequest.go @@ -0,0 +1,60 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadRestoreRequest{} + +type AzureWorkloadRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadRestoreRequest{} + +func (s AzureWorkloadRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..0aab6e728c2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,61 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..cf33fa588c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,62 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..94a74050cf7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,60 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadSAPHanaRestoreRequest{} + +type AzureWorkloadSAPHanaRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreRequest{} + +func (s AzureWorkloadSAPHanaRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..3188bc547b0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,61 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaRestoreWithRehydrateRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..ac99c3316c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,64 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreRequest{} + +type AzureWorkloadSQLPointInTimeRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..b00fdea950a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,65 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..ac2c490d397 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,63 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadSQLRestoreRequest{} + +type AzureWorkloadSQLRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreRequest{} + +func (s AzureWorkloadSQLRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..941f53d1277 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,64 @@ +package operation + +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 _ RestoreRequest = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_encryptiondetails.go new file mode 100644 index 00000000000..503730b066e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_encryptiondetails.go @@ -0,0 +1,12 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionDetails struct { + EncryptionEnabled *bool `json:"encryptionEnabled,omitempty"` + KekURL *string `json:"kekUrl,omitempty"` + KekVaultId *string `json:"kekVaultId,omitempty"` + SecretKeyURL *string `json:"secretKeyUrl,omitempty"` + SecretKeyVaultId *string `json:"secretKeyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_errordetail.go new file mode 100644 index 00000000000..2c609c87024 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_errordetail.go @@ -0,0 +1,10 @@ +package operation + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_extendedlocation.go new file mode 100644 index 00000000000..42ab6a6a9d4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_extendedlocation.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..b949f5784b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_iaasvmrestorerequest.go @@ -0,0 +1,76 @@ +package operation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreRequest{} + +type IaasVMRestoreRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s IaasVMRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = IaasVMRestoreRequest{} + +func (s IaasVMRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreRequest: %+v", err) + } + + decoded["objectType"] = "IaasVMRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..b9a50095b8f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,77 @@ +package operation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreWithRehydrationRequest{} + +type IaasVMRestoreWithRehydrationRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s IaasVMRestoreWithRehydrationRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = IaasVMRestoreWithRehydrationRequest{} + +func (s IaasVMRestoreWithRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreWithRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + decoded["objectType"] = "IaasVMRestoreWithRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..dd5d66a7e1c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_identitybasedrestoredetails.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityBasedRestoreDetails struct { + ObjectType *string `json:"objectType,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_identityinfo.go new file mode 100644 index 00000000000..e6971151557 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_identityinfo.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityInfo struct { + IsSystemAssignedIdentity *bool `json:"isSystemAssignedIdentity,omitempty"` + ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..d5d028a3fe7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_recoverypointrehydrationinfo.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointRehydrationInfo struct { + RehydrationPriority *RehydrationPriority `json:"rehydrationPriority,omitempty"` + RehydrationRetentionDuration *string `json:"rehydrationRetentionDuration,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_restorefilespecs.go new file mode 100644 index 00000000000..74e8852a5f7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_restorefilespecs.go @@ -0,0 +1,10 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFileSpecs struct { + FileSpecType *string `json:"fileSpecType,omitempty"` + Path *string `json:"path,omitempty"` + TargetFolderPath *string `json:"targetFolderPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_restorerequest.go new file mode 100644 index 00000000000..375b049a206 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_restorerequest.go @@ -0,0 +1,172 @@ +package operation + +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 RestoreRequest interface { + RestoreRequest() BaseRestoreRequestImpl +} + +var _ RestoreRequest = BaseRestoreRequestImpl{} + +type BaseRestoreRequestImpl struct { + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s BaseRestoreRequestImpl) RestoreRequest() BaseRestoreRequestImpl { + return s +} + +var _ RestoreRequest = RawRestoreRequestImpl{} + +// RawRestoreRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRestoreRequestImpl struct { + restoreRequest BaseRestoreRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawRestoreRequestImpl) RestoreRequest() BaseRestoreRequestImpl { + return s.restoreRequest +} + +func UnmarshalRestoreRequestImplementation(input []byte) (RestoreRequest, 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 RestoreRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureFileShareRestoreRequest") { + var out AzureFileShareRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRestoreRequest") { + var out AzureWorkloadPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRestoreRequest") { + var out AzureWorkloadRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreRequest") { + var out AzureWorkloadSAPHanaRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreRequest") { + var out AzureWorkloadSQLPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreRequest") { + var out AzureWorkloadSQLRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreRequest") { + var out IaasVMRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreWithRehydrationRequest") { + var out IaasVMRestoreWithRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreWithRehydrationRequest: %+v", err) + } + return out, nil + } + + var parent BaseRestoreRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRestoreRequestImpl: %+v", err) + } + + return RawRestoreRequestImpl{ + restoreRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_securedvmdetails.go new file mode 100644 index 00000000000..3f5c4c4f17a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_securedvmdetails.go @@ -0,0 +1,8 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuredVMDetails struct { + SecuredVMOsDiskEncryptionSetId *string `json:"securedVMOsDiskEncryptionSetId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..100aca8fc56 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_snapshotrestoreparameters.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreParameters struct { + LogPointInTimeForDBRecovery *string `json:"logPointInTimeForDBRecovery,omitempty"` + SkipAttachAndMount *bool `json:"skipAttachAndMount,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..9de6dd3d184 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_sqldatadirectorymapping.go @@ -0,0 +1,11 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectoryMapping struct { + MappingType *SQLDataDirectoryType `json:"mappingType,omitempty"` + SourceLogicalName *string `json:"sourceLogicalName,omitempty"` + SourcePath *string `json:"sourcePath,omitempty"` + TargetPath *string `json:"targetPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..56b7218e6de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetafsrestoreinfo.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetAFSRestoreInfo struct { + Name *string `json:"name,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..a900401068b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetdisknetworkaccesssettings.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetDiskNetworkAccessSettings struct { + TargetDiskAccessId *string `json:"targetDiskAccessId,omitempty"` + TargetDiskNetworkAccessOption *TargetDiskNetworkAccessOption `json:"targetDiskNetworkAccessOption,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetrestoreinfo.go new file mode 100644 index 00000000000..4d4171906ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_targetrestoreinfo.go @@ -0,0 +1,11 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetRestoreInfo struct { + ContainerId *string `json:"containerId,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + OverwriteOption *OverwriteOptions `json:"overwriteOption,omitempty"` + TargetDirectoryForFileRestore *string `json:"targetDirectoryForFileRestore,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..d0776af4b85 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..4000e7813ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateiaasvmrestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateiaasvmrestoreoperationrequest.go new file mode 100644 index 00000000000..01d55fc3961 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateiaasvmrestoreoperationrequest.go @@ -0,0 +1,78 @@ +package operation + +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 _ ValidateOperationRequest = ValidateIaasVMRestoreOperationRequest{} + +type ValidateIaasVMRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest + + ObjectType string `json:"objectType"` +} + +func (s ValidateIaasVMRestoreOperationRequest) ValidateOperationRequest() BaseValidateOperationRequestImpl { + return BaseValidateOperationRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = ValidateIaasVMRestoreOperationRequest{} + +func (s ValidateIaasVMRestoreOperationRequest) MarshalJSON() ([]byte, error) { + type wrapper ValidateIaasVMRestoreOperationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + decoded["objectType"] = "ValidateIaasVMRestoreOperationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ValidateIaasVMRestoreOperationRequest{} + +func (s *ValidateIaasVMRestoreOperationRequest) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ObjectType string `json:"objectType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ObjectType = decoded.ObjectType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateIaasVMRestoreOperationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequest"]; ok { + impl, err := UnmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequest' for 'ValidateIaasVMRestoreOperationRequest': %+v", err) + } + s.RestoreRequest = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationrequest.go new file mode 100644 index 00000000000..6097db60112 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationrequest.go @@ -0,0 +1,83 @@ +package operation + +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 ValidateOperationRequest interface { + ValidateOperationRequest() BaseValidateOperationRequestImpl +} + +var _ ValidateOperationRequest = BaseValidateOperationRequestImpl{} + +type BaseValidateOperationRequestImpl struct { + ObjectType string `json:"objectType"` +} + +func (s BaseValidateOperationRequestImpl) ValidateOperationRequest() BaseValidateOperationRequestImpl { + return s +} + +var _ ValidateOperationRequest = RawValidateOperationRequestImpl{} + +// RawValidateOperationRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawValidateOperationRequestImpl struct { + validateOperationRequest BaseValidateOperationRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawValidateOperationRequestImpl) ValidateOperationRequest() BaseValidateOperationRequestImpl { + return s.validateOperationRequest +} + +func UnmarshalValidateOperationRequestImplementation(input []byte) (ValidateOperationRequest, 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 ValidateOperationRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "ValidateIaasVMRestoreOperationRequest") { + var out ValidateIaasVMRestoreOperationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ValidateIaasVMRestoreOperationRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ValidateRestoreOperationRequest") { + var out ValidateRestoreOperationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ValidateRestoreOperationRequest: %+v", err) + } + return out, nil + } + + var parent BaseValidateOperationRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseValidateOperationRequestImpl: %+v", err) + } + + return RawValidateOperationRequestImpl{ + validateOperationRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationrequestresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationrequestresource.go new file mode 100644 index 00000000000..da017bc172d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationrequestresource.go @@ -0,0 +1,42 @@ +package operation + +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 ValidateOperationRequestResource struct { + Id string `json:"id"` + Properties ValidateOperationRequest `json:"properties"` +} + +var _ json.Unmarshaler = &ValidateOperationRequestResource{} + +func (s *ValidateOperationRequestResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id string `json:"id"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateOperationRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalValidateOperationRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ValidateOperationRequestResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationresponse.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationresponse.go new file mode 100644 index 00000000000..0be2ef4af18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationresponse.go @@ -0,0 +1,8 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + ValidationResults *[]ErrorDetail `json:"validationResults,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationsresponse.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationsresponse.go new file mode 100644 index 00000000000..8b9f3991c07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validateoperationsresponse.go @@ -0,0 +1,8 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationsResponse struct { + ValidateOperationResponse *ValidateOperationResponse `json:"validateOperationResponse,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validaterestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validaterestoreoperationrequest.go new file mode 100644 index 00000000000..20e3be73bd3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/model_validaterestoreoperationrequest.go @@ -0,0 +1,78 @@ +package operation + +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 _ ValidateOperationRequest = ValidateRestoreOperationRequest{} + +type ValidateRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest + + ObjectType string `json:"objectType"` +} + +func (s ValidateRestoreOperationRequest) ValidateOperationRequest() BaseValidateOperationRequestImpl { + return BaseValidateOperationRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = ValidateRestoreOperationRequest{} + +func (s ValidateRestoreOperationRequest) MarshalJSON() ([]byte, error) { + type wrapper ValidateRestoreOperationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ValidateRestoreOperationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateRestoreOperationRequest: %+v", err) + } + + decoded["objectType"] = "ValidateRestoreOperationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ValidateRestoreOperationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ValidateRestoreOperationRequest{} + +func (s *ValidateRestoreOperationRequest) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ObjectType string `json:"objectType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ObjectType = decoded.ObjectType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateRestoreOperationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequest"]; ok { + impl, err := UnmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequest' for 'ValidateRestoreOperationRequest': %+v", err) + } + s.RestoreRequest = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/operation/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/operation/version.go new file mode 100644 index 00000000000..f1340c51eab --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/operation/version.go @@ -0,0 +1,10 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/operation/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/README.md new file mode 100644 index 00000000000..362db1a55e7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection` Documentation + +The `privateendpointconnection` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/privateendpointconnection" +``` + + +### Client Initialization + +```go +client := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "privateEndpointConnectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "privateEndpointConnectionName") + +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: `PrivateEndpointConnectionClient.Put` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "privateEndpointConnectionName") + +payload := privateendpointconnection.PrivateEndpointConnectionResource{ + // ... +} + + +if err := client.PutThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/client.go new file mode 100644 index 00000000000..6acd77b913c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/client.go @@ -0,0 +1,18 @@ +package privateendpointconnection + +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 PrivateEndpointConnectionClient struct { + Client autorest.Client + baseUri string +} + +func NewPrivateEndpointConnectionClientWithBaseURI(endpoint string) PrivateEndpointConnectionClient { + return PrivateEndpointConnectionClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/constants.go new file mode 100644 index 00000000000..1b184d21326 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/constants.go @@ -0,0 +1,107 @@ +package privateendpointconnection + +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 PrivateEndpointConnectionStatus string + +const ( + PrivateEndpointConnectionStatusApproved PrivateEndpointConnectionStatus = "Approved" + PrivateEndpointConnectionStatusDisconnected PrivateEndpointConnectionStatus = "Disconnected" + PrivateEndpointConnectionStatusPending PrivateEndpointConnectionStatus = "Pending" + PrivateEndpointConnectionStatusRejected PrivateEndpointConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointConnectionStatus() []string { + return []string{ + string(PrivateEndpointConnectionStatusApproved), + string(PrivateEndpointConnectionStatusDisconnected), + string(PrivateEndpointConnectionStatusPending), + string(PrivateEndpointConnectionStatusRejected), + } +} + +func parsePrivateEndpointConnectionStatus(input string) (*PrivateEndpointConnectionStatus, error) { + vals := map[string]PrivateEndpointConnectionStatus{ + "approved": PrivateEndpointConnectionStatusApproved, + "disconnected": PrivateEndpointConnectionStatusDisconnected, + "pending": PrivateEndpointConnectionStatusPending, + "rejected": PrivateEndpointConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStatePending ProvisioningState = "Pending" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStatePending), + string(ProvisioningStateSucceeded), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "pending": ProvisioningStatePending, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type VaultSubResourceType string + +const ( + VaultSubResourceTypeAzureBackup VaultSubResourceType = "AzureBackup" + VaultSubResourceTypeAzureBackupSecondary VaultSubResourceType = "AzureBackup_secondary" + VaultSubResourceTypeAzureSiteRecovery VaultSubResourceType = "AzureSiteRecovery" +) + +func PossibleValuesForVaultSubResourceType() []string { + return []string{ + string(VaultSubResourceTypeAzureBackup), + string(VaultSubResourceTypeAzureBackupSecondary), + string(VaultSubResourceTypeAzureSiteRecovery), + } +} + +func parseVaultSubResourceType(input string) (*VaultSubResourceType, error) { + vals := map[string]VaultSubResourceType{ + "azurebackup": VaultSubResourceTypeAzureBackup, + "azurebackup_secondary": VaultSubResourceTypeAzureBackupSecondary, + "azuresiterecovery": VaultSubResourceTypeAzureSiteRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultSubResourceType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/id_privateendpointconnection.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/id_privateendpointconnection.go new file mode 100644 index 00000000000..ed2cf77fc70 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnection + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, vaultName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) 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", "vaultName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) 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("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/id_privateendpointconnection_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..51fa0302d12 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnection + +import ( + "testing" + + "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 = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_delete_autorest.go new file mode 100644 index 00000000000..7e8532d71b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_delete_autorest.go @@ -0,0 +1,78 @@ +package privateendpointconnection + +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 PrivateEndpointConnectionClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) 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 PrivateEndpointConnectionClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*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 PrivateEndpointConnectionClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_get_autorest.go new file mode 100644 index 00000000000..d5309175155 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_get_autorest.go @@ -0,0 +1,68 @@ +package privateendpointconnection + +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 *PrivateEndpointConnectionResource +} + +// Get ... +func (c PrivateEndpointConnectionClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c PrivateEndpointConnectionClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*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 PrivateEndpointConnectionClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_put_autorest.go new file mode 100644 index 00000000000..072a1c747d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/method_put_autorest.go @@ -0,0 +1,80 @@ +package privateendpointconnection + +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 PutOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response + Model *PrivateEndpointConnectionResource +} + +// Put ... +func (c PrivateEndpointConnectionClient) Put(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionResource) (result PutOperationResponse, err error) { + req, err := c.preparerForPut(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Put", nil, "Failure preparing request") + return + } + + result, err = c.senderForPut(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Put", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// PutThenPoll performs Put then polls until it's completed +func (c PrivateEndpointConnectionClient) PutThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionResource) error { + result, err := c.Put(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Put: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Put: %+v", err) + } + + return nil +} + +// preparerForPut prepares the Put request. +func (c PrivateEndpointConnectionClient) preparerForPut(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionResource) (*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)) +} + +// senderForPut sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (c PrivateEndpointConnectionClient) senderForPut(ctx context.Context, req *http.Request) (future PutOperationResponse, 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/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpoint.go new file mode 100644 index 00000000000..36d044c72d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpoint.go @@ -0,0 +1,8 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpointconnection.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpointconnection.go new file mode 100644 index 00000000000..0acbbb1f932 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + GroupIds *[]VaultSubResourceType `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpointconnectionresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpointconnectionresource.go new file mode 100644 index 00000000000..e3f0f4f5c74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privateendpointconnectionresource.go @@ -0,0 +1,14 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnection `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..81c55145a70 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/version.go new file mode 100644 index 00000000000..b8a74afce5b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/privateendpointconnection/version.go @@ -0,0 +1,10 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpointconnection/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/README.md new file mode 100644 index 00000000000..b18725753b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers` Documentation + +The `protectablecontainers` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/protectablecontainers" +``` + + +### Client Initialization + +```go +client := protectablecontainers.NewProtectableContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectableContainersClient.List` + +```go +ctx := context.TODO() +id := protectablecontainers.NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName") + +// alternatively `client.List(ctx, id, protectablecontainers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, protectablecontainers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/client.go new file mode 100644 index 00000000000..3d5274d457a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/client.go @@ -0,0 +1,18 @@ +package protectablecontainers + +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 ProtectableContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectableContainersClientWithBaseURI(endpoint string) ProtectableContainersClient { + return ProtectableContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/constants.go new file mode 100644 index 00000000000..0f5cac0dec3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/constants.go @@ -0,0 +1,133 @@ +package protectablecontainers + +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 ProtectableContainerType string + +const ( + ProtectableContainerTypeAzureBackupServerContainer ProtectableContainerType = "AzureBackupServerContainer" + ProtectableContainerTypeAzureSqlContainer ProtectableContainerType = "AzureSqlContainer" + ProtectableContainerTypeAzureWorkloadContainer ProtectableContainerType = "AzureWorkloadContainer" + ProtectableContainerTypeCluster ProtectableContainerType = "Cluster" + ProtectableContainerTypeDPMContainer ProtectableContainerType = "DPMContainer" + ProtectableContainerTypeGenericContainer ProtectableContainerType = "GenericContainer" + ProtectableContainerTypeIaasVMContainer ProtectableContainerType = "IaasVMContainer" + ProtectableContainerTypeIaasVMServiceContainer ProtectableContainerType = "IaasVMServiceContainer" + ProtectableContainerTypeInvalid ProtectableContainerType = "Invalid" + ProtectableContainerTypeMABContainer ProtectableContainerType = "MABContainer" + ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines ProtectableContainerType = "Microsoft.ClassicCompute/virtualMachines" + ProtectableContainerTypeMicrosoftPointComputeVirtualMachines ProtectableContainerType = "Microsoft.Compute/virtualMachines" + ProtectableContainerTypeSQLAGWorkLoadContainer ProtectableContainerType = "SQLAGWorkLoadContainer" + ProtectableContainerTypeStorageContainer ProtectableContainerType = "StorageContainer" + ProtectableContainerTypeUnknown ProtectableContainerType = "Unknown" + ProtectableContainerTypeVCenter ProtectableContainerType = "VCenter" + ProtectableContainerTypeVMAppContainer ProtectableContainerType = "VMAppContainer" + ProtectableContainerTypeWindows ProtectableContainerType = "Windows" +) + +func PossibleValuesForProtectableContainerType() []string { + return []string{ + string(ProtectableContainerTypeAzureBackupServerContainer), + string(ProtectableContainerTypeAzureSqlContainer), + string(ProtectableContainerTypeAzureWorkloadContainer), + string(ProtectableContainerTypeCluster), + string(ProtectableContainerTypeDPMContainer), + string(ProtectableContainerTypeGenericContainer), + string(ProtectableContainerTypeIaasVMContainer), + string(ProtectableContainerTypeIaasVMServiceContainer), + string(ProtectableContainerTypeInvalid), + string(ProtectableContainerTypeMABContainer), + string(ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ProtectableContainerTypeMicrosoftPointComputeVirtualMachines), + string(ProtectableContainerTypeSQLAGWorkLoadContainer), + string(ProtectableContainerTypeStorageContainer), + string(ProtectableContainerTypeUnknown), + string(ProtectableContainerTypeVCenter), + string(ProtectableContainerTypeVMAppContainer), + string(ProtectableContainerTypeWindows), + } +} + +func parseProtectableContainerType(input string) (*ProtectableContainerType, error) { + vals := map[string]ProtectableContainerType{ + "azurebackupservercontainer": ProtectableContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ProtectableContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ProtectableContainerTypeAzureWorkloadContainer, + "cluster": ProtectableContainerTypeCluster, + "dpmcontainer": ProtectableContainerTypeDPMContainer, + "genericcontainer": ProtectableContainerTypeGenericContainer, + "iaasvmcontainer": ProtectableContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ProtectableContainerTypeIaasVMServiceContainer, + "invalid": ProtectableContainerTypeInvalid, + "mabcontainer": ProtectableContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ProtectableContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ProtectableContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ProtectableContainerTypeStorageContainer, + "unknown": ProtectableContainerTypeUnknown, + "vcenter": ProtectableContainerTypeVCenter, + "vmappcontainer": ProtectableContainerTypeVMAppContainer, + "windows": ProtectableContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectableContainerType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/id_backupfabric.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/id_backupfabric.go new file mode 100644 index 00000000000..6771b5d5025 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/id_backupfabric.go @@ -0,0 +1,139 @@ +package protectablecontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupFabricId{}) +} + +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) + } + + id := BackupFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := BackupFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/id_backupfabric_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/id_backupfabric_test.go new file mode 100644 index 00000000000..1d43607add8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/id_backupfabric_test.go @@ -0,0 +1,327 @@ +package protectablecontainers + +import ( + "testing" + + "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{} + +func TestNewBackupFabricID(t *testing.T) { + id := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } +} + +func TestFormatBackupFabricID(t *testing.T) { + actual := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + } +} + +func TestParseBackupFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + } +} + +func TestSegmentsForBackupFabricId(t *testing.T) { + segments := BackupFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/method_list_autorest.go new file mode 100644 index 00000000000..bdea7c60f0c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/method_list_autorest.go @@ -0,0 +1,215 @@ +package protectablecontainers + +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 *[]ProtectableContainerResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectableContainerResource +} + +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 ProtectableContainersClient) List(ctx context.Context, id BackupFabricId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c ProtectableContainersClient) preparerForList(ctx context.Context, id BackupFabricId, 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/protectableContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c ProtectableContainersClient) 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 ProtectableContainersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectableContainerResource `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, "protectablecontainers.ProtectableContainersClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c ProtectableContainersClient) ListComplete(ctx context.Context, id BackupFabricId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectableContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ProtectableContainersClient) ListCompleteMatchingPredicate(ctx context.Context, id BackupFabricId, options ListOperationOptions, predicate ProtectableContainerResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectableContainerResource, 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/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_azurestorageprotectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_azurestorageprotectablecontainer.go new file mode 100644 index 00000000000..21518eff5f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_azurestorageprotectablecontainer.go @@ -0,0 +1,57 @@ +package protectablecontainers + +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 _ ProtectableContainer = AzureStorageProtectableContainer{} + +type AzureStorageProtectableContainer struct { + + // Fields inherited from ProtectableContainer + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableContainerType ProtectableContainerType `json:"protectableContainerType"` +} + +func (s AzureStorageProtectableContainer) ProtectableContainer() BaseProtectableContainerImpl { + return BaseProtectableContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerId: s.ContainerId, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableContainerType: s.ProtectableContainerType, + } +} + +var _ json.Marshaler = AzureStorageProtectableContainer{} + +func (s AzureStorageProtectableContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageProtectableContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageProtectableContainer: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageProtectableContainer: %+v", err) + } + + decoded["protectableContainerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageProtectableContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go new file mode 100644 index 00000000000..10ed7c1a1fe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go @@ -0,0 +1,57 @@ +package protectablecontainers + +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 _ ProtectableContainer = AzureVMAppContainerProtectableContainer{} + +type AzureVMAppContainerProtectableContainer struct { + + // Fields inherited from ProtectableContainer + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableContainerType ProtectableContainerType `json:"protectableContainerType"` +} + +func (s AzureVMAppContainerProtectableContainer) ProtectableContainer() BaseProtectableContainerImpl { + return BaseProtectableContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerId: s.ContainerId, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableContainerType: s.ProtectableContainerType, + } +} + +var _ json.Marshaler = AzureVMAppContainerProtectableContainer{} + +func (s AzureVMAppContainerProtectableContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectableContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectableContainer: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectableContainer: %+v", err) + } + + decoded["protectableContainerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectableContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_protectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_protectablecontainer.go new file mode 100644 index 00000000000..7fb55011f30 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_protectablecontainer.go @@ -0,0 +1,87 @@ +package protectablecontainers + +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 ProtectableContainer interface { + ProtectableContainer() BaseProtectableContainerImpl +} + +var _ ProtectableContainer = BaseProtectableContainerImpl{} + +type BaseProtectableContainerImpl struct { + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableContainerType ProtectableContainerType `json:"protectableContainerType"` +} + +func (s BaseProtectableContainerImpl) ProtectableContainer() BaseProtectableContainerImpl { + return s +} + +var _ ProtectableContainer = RawProtectableContainerImpl{} + +// RawProtectableContainerImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectableContainerImpl struct { + protectableContainer BaseProtectableContainerImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectableContainerImpl) ProtectableContainer() BaseProtectableContainerImpl { + return s.protectableContainer +} + +func UnmarshalProtectableContainerImplementation(input []byte) (ProtectableContainer, 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 ProtectableContainer into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["protectableContainerType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageProtectableContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageProtectableContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectableContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectableContainer: %+v", err) + } + return out, nil + } + + var parent BaseProtectableContainerImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectableContainerImpl: %+v", err) + } + + return RawProtectableContainerImpl{ + protectableContainer: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_protectablecontainerresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_protectablecontainerresource.go new file mode 100644 index 00000000000..836f11dc6e9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/model_protectablecontainerresource.go @@ -0,0 +1,57 @@ +package protectablecontainers + +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 ProtectableContainerResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectableContainer `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectableContainerResource{} + +func (s *ProtectableContainerResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 ProtectableContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalProtectableContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectableContainerResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/predicates.go new file mode 100644 index 00000000000..8ce6de2e8ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/predicates.go @@ -0,0 +1,37 @@ +package protectablecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableContainerResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectableContainerResourceOperationPredicate) Matches(input ProtectableContainerResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/version.go new file mode 100644 index 00000000000..d4ab2057b36 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectablecontainers/version.go @@ -0,0 +1,10 @@ +package protectablecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/protectablecontainers/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/README.md new file mode 100644 index 00000000000..0172029075f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/README.md @@ -0,0 +1,73 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems` Documentation + +The `protecteditems` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-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", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + +payload := protecteditems.ProtectedItemResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, protecteditems.DefaultCreateOrUpdateOperationOptions()) +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", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + +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", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/client.go new file mode 100644 index 00000000000..6843a00f823 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/constants.go new file mode 100644 index 00000000000..0c22907b02d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/constants.go @@ -0,0 +1,389 @@ +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" + DataSourceTypeSAPHanaDBInstance DataSourceType = "SAPHanaDBInstance" + 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(DataSourceTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": DataSourceTypeSAPHanaDBInstance, + "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 ( + ProtectedItemStateBackupsSuspended ProtectedItemState = "BackupsSuspended" + ProtectedItemStateIRPending ProtectedItemState = "IRPending" + ProtectedItemStateInvalid ProtectedItemState = "Invalid" + ProtectedItemStateProtected ProtectedItemState = "Protected" + ProtectedItemStateProtectionError ProtectedItemState = "ProtectionError" + ProtectedItemStateProtectionPaused ProtectedItemState = "ProtectionPaused" + ProtectedItemStateProtectionStopped ProtectedItemState = "ProtectionStopped" +) + +func PossibleValuesForProtectedItemState() []string { + return []string{ + string(ProtectedItemStateBackupsSuspended), + string(ProtectedItemStateIRPending), + string(ProtectedItemStateInvalid), + string(ProtectedItemStateProtected), + string(ProtectedItemStateProtectionError), + string(ProtectedItemStateProtectionPaused), + string(ProtectedItemStateProtectionStopped), + } +} + +func parseProtectedItemState(input string) (*ProtectedItemState, error) { + vals := map[string]ProtectedItemState{ + "backupssuspended": ProtectedItemStateBackupsSuspended, + "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 ( + ProtectionStateBackupsSuspended ProtectionState = "BackupsSuspended" + ProtectionStateIRPending ProtectionState = "IRPending" + ProtectionStateInvalid ProtectionState = "Invalid" + ProtectionStateProtected ProtectionState = "Protected" + ProtectionStateProtectionError ProtectionState = "ProtectionError" + ProtectionStateProtectionPaused ProtectionState = "ProtectionPaused" + ProtectionStateProtectionStopped ProtectionState = "ProtectionStopped" +) + +func PossibleValuesForProtectionState() []string { + return []string{ + string(ProtectionStateBackupsSuspended), + string(ProtectionStateIRPending), + string(ProtectionStateInvalid), + string(ProtectionStateProtected), + string(ProtectionStateProtectionError), + string(ProtectionStateProtectionPaused), + string(ProtectionStateProtectionStopped), + } +} + +func parseProtectionState(input string) (*ProtectionState, error) { + vals := map[string]ProtectionState{ + "backupssuspended": ProtectionStateBackupsSuspended, + "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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/id_protecteditem.go new file mode 100644 index 00000000000..34219b2c35c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/id_protecteditem.go @@ -0,0 +1,157 @@ +package protecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProtectedItemId{}) +} + +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) + } + + id := ProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := ProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/id_protecteditem_test.go new file mode 100644 index 00000000000..821001a86bb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/id_protecteditem_test.go @@ -0,0 +1,417 @@ +package protecteditems + +import ( + "testing" + + "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{} + +func TestNewProtectedItemID(t *testing.T) { + id := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } + + if id.ProtectedItemName != "protectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemName") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestParseProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + ProtectedItemName: "pRoTeCtEdItEmNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestSegmentsForProtectedItemId(t *testing.T) { + segments := ProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_createorupdate_autorest.go new file mode 100644 index 00000000000..f83f85fe3ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_createorupdate_autorest.go @@ -0,0 +1,98 @@ +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 +} + +type CreateOrUpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// CreateOrUpdate ... +func (c ProtectedItemsClient) CreateOrUpdate(ctx context.Context, id ProtectedItemId, input ProtectedItemResource, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) + 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, options CreateOrUpdateOperationOptions) (*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.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + 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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_delete_autorest.go new file mode 100644 index 00000000000..ed0ba3ec7a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/method_get_autorest.go new file mode 100644 index 00000000000..feb41aa7dcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurefileshareprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurefileshareprotecteditem.go new file mode 100644 index 00000000000..36b804d722b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurefileshareprotecteditem.go @@ -0,0 +1,119 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureFileshareProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go new file mode 100644 index 00000000000..f3ee3ce37c0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go new file mode 100644 index 00000000000..71f9f7319c0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go @@ -0,0 +1,124 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureIaaSClassicComputeVMProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaascomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaascomputevmprotecteditem.go new file mode 100644 index 00000000000..91542143116 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaascomputevmprotecteditem.go @@ -0,0 +1,124 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureIaaSComputeVMProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasvmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasvmprotecteditem.go new file mode 100644 index 00000000000..950049ff22f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasvmprotecteditem.go @@ -0,0 +1,124 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureIaaSVMProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..36c092fb410 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azuresqlprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azuresqlprotecteditem.go new file mode 100644 index 00000000000..3b176f0a73c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azuresqlprotecteditem.go @@ -0,0 +1,115 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureSqlProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go new file mode 100644 index 00000000000..3b6ba503042 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadprotecteditem.go new file mode 100644 index 00000000000..a889509458c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadprotecteditem.go @@ -0,0 +1,126 @@ +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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go new file mode 100644 index 00000000000..e51960b91cf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go new file mode 100644 index 00000000000..65e48faa727 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go @@ -0,0 +1,126 @@ +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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPAseDatabaseProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go new file mode 100644 index 00000000000..12597520489 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go @@ -0,0 +1,126 @@ +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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go new file mode 100644 index 00000000000..b50285a2eb0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go @@ -0,0 +1,126 @@ +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 = AzureVMWorkloadSAPHanaDBInstanceProtectedItem{} + +type AzureVMWorkloadSAPHanaDBInstanceProtectedItem 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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSAPHanaDBInstanceProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDBInstanceProtectedItem{} + +func (s AzureVMWorkloadSAPHanaDBInstanceProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDBInstanceProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + decoded["protectedItemType"] = "AzureVmWorkloadSAPHanaDBInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go new file mode 100644 index 00000000000..a801c724049 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go @@ -0,0 +1,126 @@ +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"` + NodesList *[]DistributedNodesInfo `json:"nodesList,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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s AzureVMWorkloadSQLDatabaseProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_diskexclusionproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_diskexclusionproperties.go new file mode 100644 index 00000000000..17d722bc609 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_distributednodesinfo.go new file mode 100644 index 00000000000..a67db74854b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_distributednodesinfo.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 DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_dpmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_dpmprotecteditem.go new file mode 100644 index 00000000000..24530746968 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_dpmprotecteditem.go @@ -0,0 +1,116 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s DPMProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_dpmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_dpmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..fc6f9e8cd52 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_errordetail.go new file mode 100644 index 00000000000..e3fa04c50a3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_extendedproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_extendedproperties.go new file mode 100644 index 00000000000..fe926ccaa09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_genericprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_genericprotecteditem.go new file mode 100644 index 00000000000..744e5f75787 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_genericprotecteditem.go @@ -0,0 +1,118 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s GenericProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_kpiresourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_kpiresourcehealthdetails.go new file mode 100644 index 00000000000..6cef5da3613 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_mabfilefolderprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_mabfilefolderprotecteditem.go new file mode 100644 index 00000000000..4ab12dcc9bc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_mabfilefolderprotecteditem.go @@ -0,0 +1,119 @@ +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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s MabFileFolderProtectedItem) ProtectedItem() BaseProtectedItemImpl { + return BaseProtectedItemImpl{ + BackupManagementType: s.BackupManagementType, + BackupSetName: s.BackupSetName, + ContainerName: s.ContainerName, + CreateMode: s.CreateMode, + DeferredDeleteTimeInUTC: s.DeferredDeleteTimeInUTC, + DeferredDeleteTimeRemaining: s.DeferredDeleteTimeRemaining, + IsArchiveEnabled: s.IsArchiveEnabled, + IsDeferredDeleteScheduleUpcoming: s.IsDeferredDeleteScheduleUpcoming, + IsRehydrate: s.IsRehydrate, + IsScheduledForDeferredDelete: s.IsScheduledForDeferredDelete, + LastRecoveryPoint: s.LastRecoveryPoint, + PolicyId: s.PolicyId, + PolicyName: s.PolicyName, + ProtectedItemType: s.ProtectedItemType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + SoftDeleteRetentionPeriodInDays: s.SoftDeleteRetentionPeriodInDays, + SourceResourceId: s.SourceResourceId, + VaultId: s.VaultId, + WorkloadType: s.WorkloadType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go new file mode 100644 index 00000000000..fbb9afca971 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_protecteditem.go new file mode 100644 index 00000000000..0e96764027c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_protecteditem.go @@ -0,0 +1,189 @@ +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 { + ProtectedItem() BaseProtectedItemImpl +} + +var _ ProtectedItem = BaseProtectedItemImpl{} + +type BaseProtectedItemImpl struct { + 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"` + ProtectedItemType string `json:"protectedItemType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (s BaseProtectedItemImpl) ProtectedItem() BaseProtectedItemImpl { + return s +} + +var _ ProtectedItem = RawProtectedItemImpl{} + +// RawProtectedItemImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectedItemImpl struct { + protectedItem BaseProtectedItemImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectedItemImpl) ProtectedItem() BaseProtectedItemImpl { + return s.protectedItem +} + +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) + } + + var value string + if v, ok := temp["protectedItemType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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, "AzureVmWorkloadSAPHanaDBInstance") { + var out AzureVMWorkloadSAPHanaDBInstanceProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+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 + } + + var parent BaseProtectedItemImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectedItemImpl: %+v", err) + } + + return RawProtectedItemImpl{ + protectedItem: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_protecteditemresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_protecteditemresource.go new file mode 100644 index 00000000000..62666130ef1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_protecteditemresource.go @@ -0,0 +1,57 @@ +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 { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_resourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/model_resourcehealthdetails.go new file mode 100644 index 00000000000..86710207857 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/version.go new file mode 100644 index 00000000000..7f7d857c84c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protecteditems/version.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. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/protecteditems/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/README.md new file mode 100644 index 00000000000..170e367e730 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/README.md @@ -0,0 +1,101 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers` Documentation + +The `protectioncontainers` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-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", "vaultName", "backupFabricName", "protectionContainerName") + +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", "vaultName", "backupFabricName", "protectionContainerName") + +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", "vaultName", "backupFabricName") + +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", "vaultName", "backupFabricName", "protectionContainerName") + +payload := protectioncontainers.ProtectionContainerResource{ + // ... +} + + +if err := client.RegisterThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProtectionContainersClient.Unregister` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName") + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/client.go new file mode 100644 index 00000000000..a3766493d9d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/constants.go new file mode 100644 index 00000000000..db87464f467 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/constants.go @@ -0,0 +1,332 @@ +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" + BackupItemTypeSAPHanaDBInstance BackupItemType = "SAPHanaDBInstance" + 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(BackupItemTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": BackupItemTypeSAPHanaDBInstance, + "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 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 ProtectableContainerType string + +const ( + ProtectableContainerTypeAzureBackupServerContainer ProtectableContainerType = "AzureBackupServerContainer" + ProtectableContainerTypeAzureSqlContainer ProtectableContainerType = "AzureSqlContainer" + ProtectableContainerTypeAzureWorkloadContainer ProtectableContainerType = "AzureWorkloadContainer" + ProtectableContainerTypeCluster ProtectableContainerType = "Cluster" + ProtectableContainerTypeDPMContainer ProtectableContainerType = "DPMContainer" + ProtectableContainerTypeGenericContainer ProtectableContainerType = "GenericContainer" + ProtectableContainerTypeIaasVMContainer ProtectableContainerType = "IaasVMContainer" + ProtectableContainerTypeIaasVMServiceContainer ProtectableContainerType = "IaasVMServiceContainer" + ProtectableContainerTypeInvalid ProtectableContainerType = "Invalid" + ProtectableContainerTypeMABContainer ProtectableContainerType = "MABContainer" + ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines ProtectableContainerType = "Microsoft.ClassicCompute/virtualMachines" + ProtectableContainerTypeMicrosoftPointComputeVirtualMachines ProtectableContainerType = "Microsoft.Compute/virtualMachines" + ProtectableContainerTypeSQLAGWorkLoadContainer ProtectableContainerType = "SQLAGWorkLoadContainer" + ProtectableContainerTypeStorageContainer ProtectableContainerType = "StorageContainer" + ProtectableContainerTypeUnknown ProtectableContainerType = "Unknown" + ProtectableContainerTypeVCenter ProtectableContainerType = "VCenter" + ProtectableContainerTypeVMAppContainer ProtectableContainerType = "VMAppContainer" + ProtectableContainerTypeWindows ProtectableContainerType = "Windows" +) + +func PossibleValuesForProtectableContainerType() []string { + return []string{ + string(ProtectableContainerTypeAzureBackupServerContainer), + string(ProtectableContainerTypeAzureSqlContainer), + string(ProtectableContainerTypeAzureWorkloadContainer), + string(ProtectableContainerTypeCluster), + string(ProtectableContainerTypeDPMContainer), + string(ProtectableContainerTypeGenericContainer), + string(ProtectableContainerTypeIaasVMContainer), + string(ProtectableContainerTypeIaasVMServiceContainer), + string(ProtectableContainerTypeInvalid), + string(ProtectableContainerTypeMABContainer), + string(ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ProtectableContainerTypeMicrosoftPointComputeVirtualMachines), + string(ProtectableContainerTypeSQLAGWorkLoadContainer), + string(ProtectableContainerTypeStorageContainer), + string(ProtectableContainerTypeUnknown), + string(ProtectableContainerTypeVCenter), + string(ProtectableContainerTypeVMAppContainer), + string(ProtectableContainerTypeWindows), + } +} + +func parseProtectableContainerType(input string) (*ProtectableContainerType, error) { + vals := map[string]ProtectableContainerType{ + "azurebackupservercontainer": ProtectableContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ProtectableContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ProtectableContainerTypeAzureWorkloadContainer, + "cluster": ProtectableContainerTypeCluster, + "dpmcontainer": ProtectableContainerTypeDPMContainer, + "genericcontainer": ProtectableContainerTypeGenericContainer, + "iaasvmcontainer": ProtectableContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ProtectableContainerTypeIaasVMServiceContainer, + "invalid": ProtectableContainerTypeInvalid, + "mabcontainer": ProtectableContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ProtectableContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ProtectableContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ProtectableContainerTypeStorageContainer, + "unknown": ProtectableContainerTypeUnknown, + "vcenter": ProtectableContainerTypeVCenter, + "vmappcontainer": ProtectableContainerTypeVMAppContainer, + "windows": ProtectableContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectableContainerType(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" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + 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(WorkloadTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_backupfabric.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_backupfabric.go new file mode 100644 index 00000000000..54027e95d42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_backupfabric.go @@ -0,0 +1,139 @@ +package protectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupFabricId{}) +} + +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) + } + + id := BackupFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := BackupFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_backupfabric_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_backupfabric_test.go new file mode 100644 index 00000000000..b5023fb6f57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_backupfabric_test.go @@ -0,0 +1,327 @@ +package protectioncontainers + +import ( + "testing" + + "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{} + +func TestNewBackupFabricID(t *testing.T) { + id := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } +} + +func TestFormatBackupFabricID(t *testing.T) { + actual := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + } +} + +func TestParseBackupFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + } +} + +func TestSegmentsForBackupFabricId(t *testing.T) { + segments := BackupFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_protectioncontainer.go new file mode 100644 index 00000000000..24b0d188190 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_protectioncontainer.go @@ -0,0 +1,148 @@ +package protectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProtectionContainerId{}) +} + +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) + } + + id := ProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := ProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_protectioncontainer_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_protectioncontainer_test.go new file mode 100644 index 00000000000..e8420b88b27 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/id_protectioncontainer_test.go @@ -0,0 +1,372 @@ +package protectioncontainers + +import ( + "testing" + + "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{} + +func TestNewProtectionContainerID(t *testing.T) { + id := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } +} + +func TestFormatProtectionContainerID(t *testing.T) { + actual := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + } +} + +func TestParseProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + } +} + +func TestSegmentsForProtectionContainerId(t *testing.T) { + segments := ProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_get_autorest.go new file mode 100644 index 00000000000..07d4c710143 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_inquire_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_inquire_autorest.go new file mode 100644 index 00000000000..fb85971bffd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_refresh_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_refresh_autorest.go new file mode 100644 index 00000000000..2b4984af995 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_register_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_register_autorest.go new file mode 100644 index 00000000000..c1408bad011 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_register_autorest.go @@ -0,0 +1,80 @@ +package protectioncontainers + +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 RegisterOperationResponse struct { + Poller polling.LongRunningPoller + 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, err = c.senderForRegister(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Register", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// RegisterThenPoll performs Register then polls until it's completed +func (c ProtectionContainersClient) RegisterThenPoll(ctx context.Context, id ProtectionContainerId, input ProtectionContainerResource) error { + result, err := c.Register(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Register: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Register: %+v", err) + } + + return nil +} + +// 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)) +} + +// senderForRegister sends the Register request. The method will close the +// http.Response Body if it receives an error. +func (c ProtectionContainersClient) senderForRegister(ctx context.Context, req *http.Request) (future RegisterOperationResponse, 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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_unregister_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/method_unregister_autorest.go new file mode 100644 index 00000000000..cf4fbebe128 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..de130810d4b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurebackupservercontainer.go @@ -0,0 +1,67 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureBackupServerContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..02f526ea4c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,62 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureIaaSClassicComputeVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..69100565bb9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,62 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureIaaSComputeVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..1bcd09cb31c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,64 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..5b3f7a89b2f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azuresqlcontainer.go @@ -0,0 +1,59 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureSqlContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..bd5b7e940c4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurestoragecontainer.go @@ -0,0 +1,64 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureStorageContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..42f2ac47f42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,64 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureVMAppContainerProtectionContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..cac8bf741f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureworkloadcontainer.go @@ -0,0 +1,64 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureWorkloadContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..3306d7014ef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..2a757b599d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..a6ba705e4d5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_distributednodesinfo.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 DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..0ba451153f2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_dpmcontainer.go @@ -0,0 +1,67 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s DpmContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..608a1ba48f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_errordetail.go new file mode 100644 index 00000000000..6eac856c404 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_genericcontainer.go new file mode 100644 index 00000000000..df2338f2c31 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_genericcontainer.go @@ -0,0 +1,61 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s GenericContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..6d1b2f49b6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..7d94a3c7169 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_iaasvmcontainer.go @@ -0,0 +1,62 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s IaaSVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..53bfc1db911 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..195ee612f4e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_inquiryvalidation.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 InquiryValidation struct { + AdditionalDetail *string `json:"additionalDetail,omitempty"` + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + ProtectableItemCount *interface{} `json:"protectableItemCount,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainer.go new file mode 100644 index 00000000000..d931c212b3f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainer.go @@ -0,0 +1,66 @@ +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s MabContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..82aeca609c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..1bc3a807285 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..900f7d6d788 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_protectioncontainer.go @@ -0,0 +1,168 @@ +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 { + ProtectionContainer() BaseProtectionContainerImpl +} + +var _ ProtectionContainer = BaseProtectionContainerImpl{} + +type BaseProtectionContainerImpl struct { + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s BaseProtectionContainerImpl) ProtectionContainer() BaseProtectionContainerImpl { + return s +} + +var _ ProtectionContainer = RawProtectionContainerImpl{} + +// RawProtectionContainerImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionContainerImpl struct { + protectionContainer BaseProtectionContainerImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionContainerImpl) ProtectionContainer() BaseProtectionContainerImpl { + return s.protectionContainer +} + +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) + } + + var value string + if v, ok := temp["containerType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseProtectionContainerImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionContainerImpl: %+v", err) + } + + return RawProtectionContainerImpl{ + protectionContainer: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..b8370f71280 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_protectioncontainerresource.go @@ -0,0 +1,57 @@ +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 { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..1e9d1413743 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/version.go new file mode 100644 index 00000000000..19aae5474ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectioncontainers/version.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. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/protectioncontainers/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/README.md new file mode 100644 index 00000000000..96328a4c046 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/README.md @@ -0,0 +1,94 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent` Documentation + +The `protectionintent` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/protectionintent" +``` + + +### Client Initialization + +```go +client := protectionintent.NewProtectionIntentClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectionIntentClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := protectionintent.NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "backupProtectionIntentName") + +payload := protectionintent.ProtectionIntentResource{ + // ... +} + + +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: `ProtectionIntentClient.Delete` + +```go +ctx := context.TODO() +id := protectionintent.NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "backupProtectionIntentName") + +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: `ProtectionIntentClient.Get` + +```go +ctx := context.TODO() +id := protectionintent.NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "backupProtectionIntentName") + +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: `ProtectionIntentClient.Validate` + +```go +ctx := context.TODO() +id := protectionintent.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := protectionintent.PreValidateEnableBackupRequest{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/client.go new file mode 100644 index 00000000000..0ffe385d61d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/client.go @@ -0,0 +1,18 @@ +package protectionintent + +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 ProtectionIntentClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectionIntentClientWithBaseURI(endpoint string) ProtectionIntentClient { + return ProtectionIntentClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/constants.go new file mode 100644 index 00000000000..5b115e24a59 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/constants.go @@ -0,0 +1,281 @@ +package protectionintent + +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 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" + DataSourceTypeSAPHanaDBInstance DataSourceType = "SAPHanaDBInstance" + 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(DataSourceTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": DataSourceTypeSAPHanaDBInstance, + "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 ProtectionIntentItemType string + +const ( + ProtectionIntentItemTypeAzureResourceItem ProtectionIntentItemType = "AzureResourceItem" + ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadAutoProtectionIntent" + ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadContainerAutoProtectionIntent" + ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadSQLAutoProtectionIntent" + ProtectionIntentItemTypeInvalid ProtectionIntentItemType = "Invalid" + ProtectionIntentItemTypeRecoveryServiceVaultItem ProtectionIntentItemType = "RecoveryServiceVaultItem" +) + +func PossibleValuesForProtectionIntentItemType() []string { + return []string{ + string(ProtectionIntentItemTypeAzureResourceItem), + string(ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent), + string(ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent), + string(ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent), + string(ProtectionIntentItemTypeInvalid), + string(ProtectionIntentItemTypeRecoveryServiceVaultItem), + } +} + +func parseProtectionIntentItemType(input string) (*ProtectionIntentItemType, error) { + vals := map[string]ProtectionIntentItemType{ + "azureresourceitem": ProtectionIntentItemTypeAzureResourceItem, + "azureworkloadautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent, + "azureworkloadcontainerautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent, + "azureworkloadsqlautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent, + "invalid": ProtectionIntentItemTypeInvalid, + "recoveryservicevaultitem": ProtectionIntentItemTypeRecoveryServiceVaultItem, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionIntentItemType(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 +} + +type ValidationStatus string + +const ( + ValidationStatusFailed ValidationStatus = "Failed" + ValidationStatusInvalid ValidationStatus = "Invalid" + ValidationStatusSucceeded ValidationStatus = "Succeeded" +) + +func PossibleValuesForValidationStatus() []string { + return []string{ + string(ValidationStatusFailed), + string(ValidationStatusInvalid), + string(ValidationStatusSucceeded), + } +} + +func parseValidationStatus(input string) (*ValidationStatus, error) { + vals := map[string]ValidationStatus{ + "failed": ValidationStatusFailed, + "invalid": ValidationStatusInvalid, + "succeeded": ValidationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationStatus(input) + return &out, nil +} + +type WorkloadItemType string + +const ( + WorkloadItemTypeInvalid WorkloadItemType = "Invalid" + WorkloadItemTypeSAPAseDatabase WorkloadItemType = "SAPAseDatabase" + WorkloadItemTypeSAPAseSystem WorkloadItemType = "SAPAseSystem" + WorkloadItemTypeSAPHanaDBInstance WorkloadItemType = "SAPHanaDBInstance" + WorkloadItemTypeSAPHanaDatabase WorkloadItemType = "SAPHanaDatabase" + WorkloadItemTypeSAPHanaSystem WorkloadItemType = "SAPHanaSystem" + WorkloadItemTypeSQLDataBase WorkloadItemType = "SQLDataBase" + WorkloadItemTypeSQLInstance WorkloadItemType = "SQLInstance" +) + +func PossibleValuesForWorkloadItemType() []string { + return []string{ + string(WorkloadItemTypeInvalid), + string(WorkloadItemTypeSAPAseDatabase), + string(WorkloadItemTypeSAPAseSystem), + string(WorkloadItemTypeSAPHanaDBInstance), + string(WorkloadItemTypeSAPHanaDatabase), + string(WorkloadItemTypeSAPHanaSystem), + string(WorkloadItemTypeSQLDataBase), + string(WorkloadItemTypeSQLInstance), + } +} + +func parseWorkloadItemType(input string) (*WorkloadItemType, error) { + vals := map[string]WorkloadItemType{ + "invalid": WorkloadItemTypeInvalid, + "sapasedatabase": WorkloadItemTypeSAPAseDatabase, + "sapasesystem": WorkloadItemTypeSAPAseSystem, + "saphanadbinstance": WorkloadItemTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadItemTypeSAPHanaDatabase, + "saphanasystem": WorkloadItemTypeSAPHanaSystem, + "sqldatabase": WorkloadItemTypeSQLDataBase, + "sqlinstance": WorkloadItemTypeSQLInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadItemType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_backupprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_backupprotectionintent.go new file mode 100644 index 00000000000..688d4fb97af --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_backupprotectionintent.go @@ -0,0 +1,148 @@ +package protectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupProtectionIntentId{}) +} + +var _ resourceids.ResourceId = &BackupProtectionIntentId{} + +// BackupProtectionIntentId is a struct representing the Resource ID for a Backup Protection Intent +type BackupProtectionIntentId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + BackupProtectionIntentName string +} + +// NewBackupProtectionIntentID returns a new BackupProtectionIntentId struct +func NewBackupProtectionIntentID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, backupProtectionIntentName string) BackupProtectionIntentId { + return BackupProtectionIntentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + BackupProtectionIntentName: backupProtectionIntentName, + } +} + +// ParseBackupProtectionIntentID parses 'input' into a BackupProtectionIntentId +func ParseBackupProtectionIntentID(input string) (*BackupProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupProtectionIntentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupProtectionIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupProtectionIntentIDInsensitively parses 'input' case-insensitively into a BackupProtectionIntentId +// note: this method should only be used for API response data and not user input +func ParseBackupProtectionIntentIDInsensitively(input string) (*BackupProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupProtectionIntentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupProtectionIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupProtectionIntentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.BackupProtectionIntentName, ok = input.Parsed["backupProtectionIntentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupProtectionIntentName", input) + } + + return nil +} + +// ValidateBackupProtectionIntentID checks that 'input' can be parsed as a Backup Protection Intent ID +func ValidateBackupProtectionIntentID(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 := ParseBackupProtectionIntentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Protection Intent ID +func (id BackupProtectionIntentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/backupProtectionIntent/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.BackupProtectionIntentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Protection Intent ID +func (id BackupProtectionIntentId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticBackupProtectionIntent", "backupProtectionIntent", "backupProtectionIntent"), + resourceids.UserSpecifiedSegment("backupProtectionIntentName", "backupProtectionIntentName"), + } +} + +// String returns a human-readable description of this Backup Protection Intent ID +func (id BackupProtectionIntentId) 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("Backup Protection Intent Name: %q", id.BackupProtectionIntentName), + } + return fmt.Sprintf("Backup Protection Intent (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_backupprotectionintent_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_backupprotectionintent_test.go new file mode 100644 index 00000000000..b2fd670a103 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_backupprotectionintent_test.go @@ -0,0 +1,372 @@ +package protectionintent + +import ( + "testing" + + "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 = &BackupProtectionIntentId{} + +func TestNewBackupProtectionIntentID(t *testing.T) { + id := NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "backupProtectionIntentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.BackupProtectionIntentName != "backupProtectionIntentName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupProtectionIntentName'", id.BackupProtectionIntentName, "backupProtectionIntentName") + } +} + +func TestFormatBackupProtectionIntentID(t *testing.T) { + actual := NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "backupProtectionIntentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/backupProtectionIntent/backupProtectionIntentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupProtectionIntentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupProtectionIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/backupProtectionIntent", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/backupProtectionIntent/backupProtectionIntentName", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + BackupProtectionIntentName: "backupProtectionIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/backupProtectionIntent/backupProtectionIntentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupProtectionIntentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.BackupProtectionIntentName != v.Expected.BackupProtectionIntentName { + t.Fatalf("Expected %q but got %q for BackupProtectionIntentName", v.Expected.BackupProtectionIntentName, actual.BackupProtectionIntentName) + } + + } +} + +func TestParseBackupProtectionIntentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupProtectionIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/backupProtectionIntent", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/bAcKuPpRoTeCtIoNiNtEnT", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/backupProtectionIntent/backupProtectionIntentName", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + BackupProtectionIntentName: "backupProtectionIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/backupProtectionIntent/backupProtectionIntentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/bAcKuPpRoTeCtIoNiNtEnT/bAcKuPpRoTeCtIoNiNtEnTnAmE", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + BackupProtectionIntentName: "bAcKuPpRoTeCtIoNiNtEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/bAcKuPpRoTeCtIoNiNtEnT/bAcKuPpRoTeCtIoNiNtEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupProtectionIntentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.BackupProtectionIntentName != v.Expected.BackupProtectionIntentName { + t.Fatalf("Expected %q but got %q for BackupProtectionIntentName", v.Expected.BackupProtectionIntentName, actual.BackupProtectionIntentName) + } + + } +} + +func TestSegmentsForBackupProtectionIntentId(t *testing.T) { + segments := BackupProtectionIntentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupProtectionIntentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_location.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_location.go new file mode 100644 index 00000000000..98c32ddf030 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_location.go @@ -0,0 +1,121 @@ +package protectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_location_test.go new file mode 100644 index 00000000000..091fdeda511 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/id_location_test.go @@ -0,0 +1,237 @@ +package protectionintent + +import ( + "testing" + + "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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_createorupdate_autorest.go new file mode 100644 index 00000000000..119b9b9a38a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package protectionintent + +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 *ProtectionIntentResource +} + +// CreateOrUpdate ... +func (c ProtectionIntentClient) CreateOrUpdate(ctx context.Context, id BackupProtectionIntentId, input ProtectionIntentResource) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ProtectionIntentClient) preparerForCreateOrUpdate(ctx context.Context, id BackupProtectionIntentId, input ProtectionIntentResource) (*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 ProtectionIntentClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_delete_autorest.go new file mode 100644 index 00000000000..2ed03771624 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_delete_autorest.go @@ -0,0 +1,66 @@ +package protectionintent + +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 ProtectionIntentClient) Delete(ctx context.Context, id BackupProtectionIntentId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c ProtectionIntentClient) preparerForDelete(ctx context.Context, id BackupProtectionIntentId) (*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 ProtectionIntentClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_get_autorest.go new file mode 100644 index 00000000000..0875ecb9ece --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_get_autorest.go @@ -0,0 +1,68 @@ +package protectionintent + +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 *ProtectionIntentResource +} + +// Get ... +func (c ProtectionIntentClient) Get(ctx context.Context, id BackupProtectionIntentId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProtectionIntentClient) preparerForGet(ctx context.Context, id BackupProtectionIntentId) (*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 ProtectionIntentClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_validate_autorest.go new file mode 100644 index 00000000000..677f74de02b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/method_validate_autorest.go @@ -0,0 +1,70 @@ +package protectionintent + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + HttpResponse *http.Response + Model *PreValidateEnableBackupResponse +} + +// Validate ... +func (c ProtectionIntentClient) Validate(ctx context.Context, id LocationId, input PreValidateEnableBackupRequest) (result ValidateOperationResponse, err error) { + req, err := c.preparerForValidate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Validate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Validate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForValidate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Validate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForValidate prepares the Validate request. +func (c ProtectionIntentClient) preparerForValidate(ctx context.Context, id LocationId, input PreValidateEnableBackupRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupPreValidateProtection", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForValidate handles the response to the Validate request. The method always +// closes the http.Response Body. +func (c ProtectionIntentClient) responderForValidate(resp *http.Response) (result ValidateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go new file mode 100644 index 00000000000..7d06a8fd30b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go @@ -0,0 +1,59 @@ +package protectionintent + +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 _ ProtectionIntent = AzureRecoveryServiceVaultProtectionIntent{} + +type AzureRecoveryServiceVaultProtectionIntent struct { + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureRecoveryServiceVaultProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureRecoveryServiceVaultProtectionIntent{} + +func (s AzureRecoveryServiceVaultProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureRecoveryServiceVaultProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "RecoveryServiceVaultItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureresourceprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureresourceprotectionintent.go new file mode 100644 index 00000000000..a757f8703aa --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureresourceprotectionintent.go @@ -0,0 +1,60 @@ +package protectionintent + +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 _ ProtectionIntent = AzureResourceProtectionIntent{} + +type AzureResourceProtectionIntent struct { + FriendlyName *string `json:"friendlyName,omitempty"` + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureResourceProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureResourceProtectionIntent{} + +func (s AzureResourceProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureResourceProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureResourceProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureResourceProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "AzureResourceItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureResourceProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadautoprotectionintent.go new file mode 100644 index 00000000000..013e10d9ec6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadautoprotectionintent.go @@ -0,0 +1,59 @@ +package protectionintent + +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 _ ProtectionIntent = AzureWorkloadAutoProtectionIntent{} + +type AzureWorkloadAutoProtectionIntent struct { + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureWorkloadAutoProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureWorkloadAutoProtectionIntent{} + +func (s AzureWorkloadAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "AzureWorkloadAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go new file mode 100644 index 00000000000..c26eec72d7e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go @@ -0,0 +1,59 @@ +package protectionintent + +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 _ ProtectionIntent = AzureWorkloadContainerAutoProtectionIntent{} + +type AzureWorkloadContainerAutoProtectionIntent struct { + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureWorkloadContainerAutoProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureWorkloadContainerAutoProtectionIntent{} + +func (s AzureWorkloadContainerAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainerAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "AzureWorkloadContainerAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go new file mode 100644 index 00000000000..57b98ad3c99 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go @@ -0,0 +1,60 @@ +package protectionintent + +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 _ ProtectionIntent = AzureWorkloadSQLAutoProtectionIntent{} + +type AzureWorkloadSQLAutoProtectionIntent struct { + WorkloadItemType *WorkloadItemType `json:"workloadItemType,omitempty"` + + // Fields inherited from ProtectionIntent + + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s AzureWorkloadSQLAutoProtectionIntent) ProtectionIntent() BaseProtectionIntentImpl { + return BaseProtectionIntentImpl{ + BackupManagementType: s.BackupManagementType, + ItemId: s.ItemId, + PolicyId: s.PolicyId, + ProtectionIntentItemType: s.ProtectionIntentItemType, + ProtectionState: s.ProtectionState, + SourceResourceId: s.SourceResourceId, + } +} + +var _ json.Marshaler = AzureWorkloadSQLAutoProtectionIntent{} + +func (s AzureWorkloadSQLAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + decoded["protectionIntentItemType"] = "AzureWorkloadSQLAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_prevalidateenablebackuprequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_prevalidateenablebackuprequest.go new file mode 100644 index 00000000000..58ac0096b74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_prevalidateenablebackuprequest.go @@ -0,0 +1,11 @@ +package protectionintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreValidateEnableBackupRequest struct { + Properties *string `json:"properties,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceType *DataSourceType `json:"resourceType,omitempty"` + VaultId *string `json:"vaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_prevalidateenablebackupresponse.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_prevalidateenablebackupresponse.go new file mode 100644 index 00000000000..456761b757d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_prevalidateenablebackupresponse.go @@ -0,0 +1,13 @@ +package protectionintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreValidateEnableBackupResponse struct { + ContainerName *string `json:"containerName,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + Recommendation *string `json:"recommendation,omitempty"` + Status *ValidationStatus `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_protectionintent.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_protectionintent.go new file mode 100644 index 00000000000..7b15854f3c2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_protectionintent.go @@ -0,0 +1,112 @@ +package protectionintent + +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 ProtectionIntent interface { + ProtectionIntent() BaseProtectionIntentImpl +} + +var _ ProtectionIntent = BaseProtectionIntentImpl{} + +type BaseProtectionIntentImpl struct { + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionIntentItemType ProtectionIntentItemType `json:"protectionIntentItemType"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +func (s BaseProtectionIntentImpl) ProtectionIntent() BaseProtectionIntentImpl { + return s +} + +var _ ProtectionIntent = RawProtectionIntentImpl{} + +// RawProtectionIntentImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionIntentImpl struct { + protectionIntent BaseProtectionIntentImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionIntentImpl) ProtectionIntent() BaseProtectionIntentImpl { + return s.protectionIntent +} + +func UnmarshalProtectionIntentImplementation(input []byte) (ProtectionIntent, 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 ProtectionIntent into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["protectionIntentItemType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "RecoveryServiceVaultItem") { + var out AzureRecoveryServiceVaultProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureResourceItem") { + var out AzureResourceProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureResourceProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadAutoProtectionIntent") { + var out AzureWorkloadAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadAutoProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainerAutoProtectionIntent") { + var out AzureWorkloadContainerAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLAutoProtectionIntent") { + var out AzureWorkloadSQLAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + return out, nil + } + + var parent BaseProtectionIntentImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionIntentImpl: %+v", err) + } + + return RawProtectionIntentImpl{ + protectionIntent: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_protectionintentresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_protectionintentresource.go new file mode 100644 index 00000000000..c92be6a6af3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/model_protectionintentresource.go @@ -0,0 +1,57 @@ +package protectionintent + +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 ProtectionIntentResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionIntent `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionIntentResource{} + +func (s *ProtectionIntentResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 ProtectionIntentResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalProtectionIntentImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionIntentResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/version.go new file mode 100644 index 00000000000..5bec2486041 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionintent/version.go @@ -0,0 +1,10 @@ +package protectionintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/protectionintent/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/README.md new file mode 100644 index 00000000000..a71b6ed82b9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies` Documentation + +The `protectionpolicies` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-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", "vaultName", "backupPolicyName") + +payload := protectionpolicies.ProtectionPolicyResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, protectionpolicies.DefaultCreateOrUpdateOperationOptions()) +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", "vaultName", "backupPolicyName") + +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", "vaultName", "backupPolicyName") + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/client.go new file mode 100644 index 00000000000..af96d5ee4b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/constants.go new file mode 100644 index 00000000000..d3b05f5ef64 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/constants.go @@ -0,0 +1,460 @@ +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 IaasVMSnapshotConsistencyType string + +const ( + IaasVMSnapshotConsistencyTypeOnlyCrashConsistent IaasVMSnapshotConsistencyType = "OnlyCrashConsistent" +) + +func PossibleValuesForIaasVMSnapshotConsistencyType() []string { + return []string{ + string(IaasVMSnapshotConsistencyTypeOnlyCrashConsistent), + } +} + +func parseIaasVMSnapshotConsistencyType(input string) (*IaasVMSnapshotConsistencyType, error) { + vals := map[string]IaasVMSnapshotConsistencyType{ + "onlycrashconsistent": IaasVMSnapshotConsistencyTypeOnlyCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IaasVMSnapshotConsistencyType(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" + PolicyTypeSnapshotCopyOnlyFull PolicyType = "SnapshotCopyOnlyFull" + PolicyTypeSnapshotFull PolicyType = "SnapshotFull" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeCopyOnlyFull), + string(PolicyTypeDifferential), + string(PolicyTypeFull), + string(PolicyTypeIncremental), + string(PolicyTypeInvalid), + string(PolicyTypeLog), + string(PolicyTypeSnapshotCopyOnlyFull), + string(PolicyTypeSnapshotFull), + } +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "copyonlyfull": PolicyTypeCopyOnlyFull, + "differential": PolicyTypeDifferential, + "full": PolicyTypeFull, + "incremental": PolicyTypeIncremental, + "invalid": PolicyTypeInvalid, + "log": PolicyTypeLog, + "snapshotcopyonlyfull": PolicyTypeSnapshotCopyOnlyFull, + "snapshotfull": PolicyTypeSnapshotFull, + } + 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" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + 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(WorkloadTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/id_backuppolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/id_backuppolicy.go new file mode 100644 index 00000000000..238e1a3ecf0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/id_backuppolicy.go @@ -0,0 +1,139 @@ +package protectionpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupPolicyId{}) +} + +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) + } + + id := BackupPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := BackupPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupPolicyName, ok = input.Parsed["backupPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupPolicyName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupPolicies", "backupPolicies", "backupPolicies"), + resourceids.UserSpecifiedSegment("backupPolicyName", "backupPolicyName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/id_backuppolicy_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/id_backuppolicy_test.go new file mode 100644 index 00000000000..ee84948a820 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/id_backuppolicy_test.go @@ -0,0 +1,327 @@ +package protectionpolicies + +import ( + "testing" + + "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{} + +func TestNewBackupPolicyID(t *testing.T) { + id := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupPolicyName != "backupPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupPolicyName'", id.BackupPolicyName, "backupPolicyName") + } +} + +func TestFormatBackupPolicyID(t *testing.T) { + actual := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupPolicies/backupPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupPolicies/backupPolicyName", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupPolicyName: "backupPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupPolicies/backupPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupPolicyName != v.Expected.BackupPolicyName { + t.Fatalf("Expected %q but got %q for BackupPolicyName", v.Expected.BackupPolicyName, actual.BackupPolicyName) + } + + } +} + +func TestParseBackupPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupPolicies/backupPolicyName", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupPolicyName: "backupPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupPolicies/backupPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPpOlIcIeS/bAcKuPpOlIcYnAmE", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupPolicyName: "bAcKuPpOlIcYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPpOlIcIeS/bAcKuPpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupPolicyName != v.Expected.BackupPolicyName { + t.Fatalf("Expected %q but got %q for BackupPolicyName", v.Expected.BackupPolicyName, actual.BackupPolicyName) + } + + } +} + +func TestSegmentsForBackupPolicyId(t *testing.T) { + segments := BackupPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_createorupdate_autorest.go new file mode 100644 index 00000000000..24443b25235 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_createorupdate_autorest.go @@ -0,0 +1,98 @@ +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 +} + +type CreateOrUpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// CreateOrUpdate ... +func (c ProtectionPoliciesClient) CreateOrUpdate(ctx context.Context, id BackupPolicyId, input ProtectionPolicyResource, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) + 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, options CreateOrUpdateOperationOptions) (*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.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + 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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_delete_autorest.go new file mode 100644 index 00000000000..d8310df327c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/method_get_autorest.go new file mode 100644 index 00000000000..bd3aabebfe7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azurefileshareprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azurefileshareprotectionpolicy.go new file mode 100644 index 00000000000..6c189a502cc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azurefileshareprotectionpolicy.go @@ -0,0 +1,104 @@ +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"` + VaultRetentionPolicy *VaultRetentionPolicy `json:"vaultRetentionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureFileShareProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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 { + var decoded struct { + TimeZone *string `json:"timeZone,omitempty"` + VaultRetentionPolicy *VaultRetentionPolicy `json:"vaultRetentionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.TimeZone = decoded.TimeZone + s.VaultRetentionPolicy = decoded.VaultRetentionPolicy + s.WorkLoadType = decoded.WorkLoadType + s.BackupManagementType = decoded.BackupManagementType + 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 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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go new file mode 100644 index 00000000000..6e6b7945d35 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go @@ -0,0 +1,113 @@ +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"` + SnapshotConsistencyType *IaasVMSnapshotConsistencyType `json:"snapshotConsistencyType,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureIaaSVMProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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 { + var decoded struct { + InstantRPDetails *InstantRPAdditionalDetails `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + PolicyType *IAASVMPolicyType `json:"policyType,omitempty"` + SnapshotConsistencyType *IaasVMSnapshotConsistencyType `json:"snapshotConsistencyType,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.InstantRPDetails = decoded.InstantRPDetails + s.InstantRpRetentionRangeInDays = decoded.InstantRpRetentionRangeInDays + s.PolicyType = decoded.PolicyType + s.SnapshotConsistencyType = decoded.SnapshotConsistencyType + s.TieringPolicy = decoded.TieringPolicy + s.TimeZone = decoded.TimeZone + s.BackupManagementType = decoded.BackupManagementType + 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 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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azuresqlprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azuresqlprotectionpolicy.go new file mode 100644 index 00000000000..da6d56b3a0f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azuresqlprotectionpolicy.go @@ -0,0 +1,86 @@ +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 + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureSqlProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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 { + var decoded struct { + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BackupManagementType = decoded.BackupManagementType + 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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go new file mode 100644 index 00000000000..312859e45fa --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go @@ -0,0 +1,57 @@ +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 + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureVMWorkloadProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyretentionformat.go new file mode 100644 index 00000000000..f2f8a9c3693 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyretentionschedule.go new file mode 100644 index 00000000000..40dc38fbcda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_dailyschedule.go new file mode 100644 index 00000000000..88826749b25 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_day.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_day.go new file mode 100644 index 00000000000..ca922f3cfe2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_genericprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_genericprotectionpolicy.go new file mode 100644 index 00000000000..19ef2176821 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_genericprotectionpolicy.go @@ -0,0 +1,56 @@ +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 + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s GenericProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_hourlyschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_hourlyschedule.go new file mode 100644 index 00000000000..8e573c02a5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_instantrpadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_instantrpadditionaldetails.go new file mode 100644 index 00000000000..ea9cd7a24da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_logschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_logschedulepolicy.go new file mode 100644 index 00000000000..d7be5540a0d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_logschedulepolicy.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. + +var _ SchedulePolicy = LogSchedulePolicy{} + +type LogSchedulePolicy struct { + ScheduleFrequencyInMins *int64 `json:"scheduleFrequencyInMins,omitempty"` + + // Fields inherited from SchedulePolicy + + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s LogSchedulePolicy) SchedulePolicy() BaseSchedulePolicyImpl { + return BaseSchedulePolicyImpl{ + SchedulePolicyType: s.SchedulePolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_longtermretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_longtermretentionpolicy.go new file mode 100644 index 00000000000..370051cc454 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_longtermretentionpolicy.go @@ -0,0 +1,53 @@ +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 + + RetentionPolicyType string `json:"retentionPolicyType"` +} + +func (s LongTermRetentionPolicy) RetentionPolicy() BaseRetentionPolicyImpl { + return BaseRetentionPolicyImpl{ + RetentionPolicyType: s.RetentionPolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_longtermschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_longtermschedulepolicy.go new file mode 100644 index 00000000000..0a582bff60a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_longtermschedulepolicy.go @@ -0,0 +1,49 @@ +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 + + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s LongTermSchedulePolicy) SchedulePolicy() BaseSchedulePolicyImpl { + return BaseSchedulePolicyImpl{ + SchedulePolicyType: s.SchedulePolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_mabprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_mabprotectionpolicy.go new file mode 100644 index 00000000000..e5b25954259 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_mabprotectionpolicy.go @@ -0,0 +1,95 @@ +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 + + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s MabProtectionPolicy) ProtectionPolicy() BaseProtectionPolicyImpl { + return BaseProtectionPolicyImpl{ + BackupManagementType: s.BackupManagementType, + ProtectedItemsCount: s.ProtectedItemsCount, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +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 { + var decoded struct { + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BackupManagementType = decoded.BackupManagementType + 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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_monthlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_monthlyretentionschedule.go new file mode 100644 index 00000000000..4ceda36d875 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_protectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_protectionpolicy.go new file mode 100644 index 00000000000..a3363c720b6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_protectionpolicy.go @@ -0,0 +1,117 @@ +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 { + ProtectionPolicy() BaseProtectionPolicyImpl +} + +var _ ProtectionPolicy = BaseProtectionPolicyImpl{} + +type BaseProtectionPolicyImpl struct { + BackupManagementType string `json:"backupManagementType"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s BaseProtectionPolicyImpl) ProtectionPolicy() BaseProtectionPolicyImpl { + return s +} + +var _ ProtectionPolicy = RawProtectionPolicyImpl{} + +// RawProtectionPolicyImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionPolicyImpl struct { + protectionPolicy BaseProtectionPolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionPolicyImpl) ProtectionPolicy() BaseProtectionPolicyImpl { + return s.protectionPolicy +} + +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) + } + + var value string + if v, ok := temp["backupManagementType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseProtectionPolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionPolicyImpl: %+v", err) + } + + return RawProtectionPolicyImpl{ + protectionPolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_protectionpolicyresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_protectionpolicyresource.go new file mode 100644 index 00000000000..94fb7fdc439 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_protectionpolicyresource.go @@ -0,0 +1,57 @@ +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 { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_retentionduration.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_retentionduration.go new file mode 100644 index 00000000000..4b77b5e2f23 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_retentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_retentionpolicy.go new file mode 100644 index 00000000000..2985db55d03 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_retentionpolicy.go @@ -0,0 +1,83 @@ +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 { + RetentionPolicy() BaseRetentionPolicyImpl +} + +var _ RetentionPolicy = BaseRetentionPolicyImpl{} + +type BaseRetentionPolicyImpl struct { + RetentionPolicyType string `json:"retentionPolicyType"` +} + +func (s BaseRetentionPolicyImpl) RetentionPolicy() BaseRetentionPolicyImpl { + return s +} + +var _ RetentionPolicy = RawRetentionPolicyImpl{} + +// RawRetentionPolicyImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRetentionPolicyImpl struct { + retentionPolicy BaseRetentionPolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawRetentionPolicyImpl) RetentionPolicy() BaseRetentionPolicyImpl { + return s.retentionPolicy +} + +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) + } + + var value string + if v, ok := temp["retentionPolicyType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseRetentionPolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRetentionPolicyImpl: %+v", err) + } + + return RawRetentionPolicyImpl{ + retentionPolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_schedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_schedulepolicy.go new file mode 100644 index 00000000000..717c2316f09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_schedulepolicy.go @@ -0,0 +1,99 @@ +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 { + SchedulePolicy() BaseSchedulePolicyImpl +} + +var _ SchedulePolicy = BaseSchedulePolicyImpl{} + +type BaseSchedulePolicyImpl struct { + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s BaseSchedulePolicyImpl) SchedulePolicy() BaseSchedulePolicyImpl { + return s +} + +var _ SchedulePolicy = RawSchedulePolicyImpl{} + +// RawSchedulePolicyImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSchedulePolicyImpl struct { + schedulePolicy BaseSchedulePolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawSchedulePolicyImpl) SchedulePolicy() BaseSchedulePolicyImpl { + return s.schedulePolicy +} + +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) + } + + var value string + if v, ok := temp["schedulePolicyType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseSchedulePolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSchedulePolicyImpl: %+v", err) + } + + return RawSchedulePolicyImpl{ + schedulePolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_settings.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_settings.go new file mode 100644 index 00000000000..585e96708fc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleretentionpolicy.go new file mode 100644 index 00000000000..8481b97b705 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleretentionpolicy.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. + +var _ RetentionPolicy = SimpleRetentionPolicy{} + +type SimpleRetentionPolicy struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + + // Fields inherited from RetentionPolicy + + RetentionPolicyType string `json:"retentionPolicyType"` +} + +func (s SimpleRetentionPolicy) RetentionPolicy() BaseRetentionPolicyImpl { + return BaseRetentionPolicyImpl{ + RetentionPolicyType: s.RetentionPolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleschedulepolicy.go new file mode 100644 index 00000000000..004acc231d5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleschedulepolicy.go @@ -0,0 +1,54 @@ +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 + + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s SimpleSchedulePolicy) SchedulePolicy() BaseSchedulePolicyImpl { + return BaseSchedulePolicyImpl{ + SchedulePolicyType: s.SchedulePolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleschedulepolicyv2.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleschedulepolicyv2.go new file mode 100644 index 00000000000..5d4f403ffb2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_simpleschedulepolicyv2.go @@ -0,0 +1,53 @@ +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 + + SchedulePolicyType string `json:"schedulePolicyType"` +} + +func (s SimpleSchedulePolicyV2) SchedulePolicy() BaseSchedulePolicyImpl { + return BaseSchedulePolicyImpl{ + SchedulePolicyType: s.SchedulePolicyType, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_snapshotbackupadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_snapshotbackupadditionaldetails.go new file mode 100644 index 00000000000..7ac85d6090e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_snapshotbackupadditionaldetails.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 SnapshotBackupAdditionalDetails struct { + InstantRPDetails *string `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_subprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_subprotectionpolicy.go new file mode 100644 index 00000000000..22005f8e4cc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_subprotectionpolicy.go @@ -0,0 +1,57 @@ +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"` + SnapshotBackupAdditionalDetails *SnapshotBackupAdditionalDetails `json:"snapshotBackupAdditionalDetails,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` +} + +var _ json.Unmarshaler = &SubProtectionPolicy{} + +func (s *SubProtectionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PolicyType *PolicyType `json:"policyType,omitempty"` + SnapshotBackupAdditionalDetails *SnapshotBackupAdditionalDetails `json:"snapshotBackupAdditionalDetails,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PolicyType = decoded.PolicyType + s.SnapshotBackupAdditionalDetails = decoded.SnapshotBackupAdditionalDetails + 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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_tieringpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_tieringpolicy.go new file mode 100644 index 00000000000..51a5c8b97f0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..7345c69f819 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_userassignedidentityproperties.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 UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..85ab2cf390a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_userassignedmanagedidentitydetails.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 UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_vaultretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_vaultretentionpolicy.go new file mode 100644 index 00000000000..28eb90f11bc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_vaultretentionpolicy.go @@ -0,0 +1,42 @@ +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 VaultRetentionPolicy struct { + SnapshotRetentionInDays int64 `json:"snapshotRetentionInDays"` + VaultRetention RetentionPolicy `json:"vaultRetention"` +} + +var _ json.Unmarshaler = &VaultRetentionPolicy{} + +func (s *VaultRetentionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded struct { + SnapshotRetentionInDays int64 `json:"snapshotRetentionInDays"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.SnapshotRetentionInDays = decoded.SnapshotRetentionInDays + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling VaultRetentionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["vaultRetention"]; ok { + impl, err := UnmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'VaultRetention' for 'VaultRetentionPolicy': %+v", err) + } + s.VaultRetention = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyretentionformat.go new file mode 100644 index 00000000000..082fcf7abe1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyretentionschedule.go new file mode 100644 index 00000000000..cde2551554d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_weeklyschedule.go new file mode 100644 index 00000000000..f3005f7015f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_yearlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/model_yearlyretentionschedule.go new file mode 100644 index 00000000000..8d300368ef5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-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/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/version.go new file mode 100644 index 00000000000..bfc42a9f05c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/protectionpolicies/version.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. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/protectionpolicies/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/README.md new file mode 100644 index 00000000000..bcb6cc91bc9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint` Documentation + +The `recoverypoint` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/recoverypoint" +``` + + +### Client Initialization + +```go +client := recoverypoint.NewRecoveryPointClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointClient.MoveRecoveryPoint` + +```go +ctx := context.TODO() +id := recoverypoint.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + +payload := recoverypoint.MoveRPAcrossTiersRequest{ + // ... +} + + +if err := client.MoveRecoveryPointThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/client.go new file mode 100644 index 00000000000..6c60cc292bc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/client.go @@ -0,0 +1,18 @@ +package recoverypoint + +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 RecoveryPointClient struct { + Client autorest.Client + baseUri string +} + +func NewRecoveryPointClientWithBaseURI(endpoint string) RecoveryPointClient { + return RecoveryPointClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/constants.go new file mode 100644 index 00000000000..9c8da179e39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/constants.go @@ -0,0 +1,42 @@ +package recoverypoint + +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 RecoveryPointTierType string + +const ( + RecoveryPointTierTypeArchivedRP RecoveryPointTierType = "ArchivedRP" + RecoveryPointTierTypeHardenedRP RecoveryPointTierType = "HardenedRP" + RecoveryPointTierTypeInstantRP RecoveryPointTierType = "InstantRP" + RecoveryPointTierTypeInvalid RecoveryPointTierType = "Invalid" +) + +func PossibleValuesForRecoveryPointTierType() []string { + return []string{ + string(RecoveryPointTierTypeArchivedRP), + string(RecoveryPointTierTypeHardenedRP), + string(RecoveryPointTierTypeInstantRP), + string(RecoveryPointTierTypeInvalid), + } +} + +func parseRecoveryPointTierType(input string) (*RecoveryPointTierType, error) { + vals := map[string]RecoveryPointTierType{ + "archivedrp": RecoveryPointTierTypeArchivedRP, + "hardenedrp": RecoveryPointTierTypeHardenedRP, + "instantrp": RecoveryPointTierTypeInstantRP, + "invalid": RecoveryPointTierTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/id_recoverypoint.go new file mode 100644 index 00000000000..f39e95f0719 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/id_recoverypoint.go @@ -0,0 +1,166 @@ +package recoverypoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(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 := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemName"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointId"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) 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), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/id_recoverypoint_test.go new file mode 100644 index 00000000000..d06d7a3f935 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package recoverypoint + +import ( + "testing" + + "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 = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } + + if id.ProtectedItemName != "protectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemName") + } + + if id.RecoveryPointId != "recoveryPointId" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointId") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + RecoveryPointId: "recoveryPointId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + RecoveryPointId: "recoveryPointId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS/rEcOvErYpOiNtId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + ProtectedItemName: "pRoTeCtEdItEmNaMe", + RecoveryPointId: "rEcOvErYpOiNtId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS/rEcOvErYpOiNtId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/method_moverecoverypoint_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/method_moverecoverypoint_autorest.go new file mode 100644 index 00000000000..77b6f679042 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/method_moverecoverypoint_autorest.go @@ -0,0 +1,79 @@ +package recoverypoint + +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 MoveRecoveryPointOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// MoveRecoveryPoint ... +func (c RecoveryPointClient) MoveRecoveryPoint(ctx context.Context, id RecoveryPointId, input MoveRPAcrossTiersRequest) (result MoveRecoveryPointOperationResponse, err error) { + req, err := c.preparerForMoveRecoveryPoint(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoint.RecoveryPointClient", "MoveRecoveryPoint", nil, "Failure preparing request") + return + } + + result, err = c.senderForMoveRecoveryPoint(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoint.RecoveryPointClient", "MoveRecoveryPoint", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// MoveRecoveryPointThenPoll performs MoveRecoveryPoint then polls until it's completed +func (c RecoveryPointClient) MoveRecoveryPointThenPoll(ctx context.Context, id RecoveryPointId, input MoveRPAcrossTiersRequest) error { + result, err := c.MoveRecoveryPoint(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MoveRecoveryPoint: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after MoveRecoveryPoint: %+v", err) + } + + return nil +} + +// preparerForMoveRecoveryPoint prepares the MoveRecoveryPoint request. +func (c RecoveryPointClient) preparerForMoveRecoveryPoint(ctx context.Context, id RecoveryPointId, input MoveRPAcrossTiersRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/move", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForMoveRecoveryPoint sends the MoveRecoveryPoint request. The method will close the +// http.Response Body if it receives an error. +func (c RecoveryPointClient) senderForMoveRecoveryPoint(ctx context.Context, req *http.Request) (future MoveRecoveryPointOperationResponse, 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/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/model_moverpacrosstiersrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/model_moverpacrosstiersrequest.go new file mode 100644 index 00000000000..c90154ae670 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/model_moverpacrosstiersrequest.go @@ -0,0 +1,10 @@ +package recoverypoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MoveRPAcrossTiersRequest struct { + ObjectType *string `json:"objectType,omitempty"` + SourceTierType *RecoveryPointTierType `json:"sourceTierType,omitempty"` + TargetTierType *RecoveryPointTierType `json:"targetTierType,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/version.go new file mode 100644 index 00000000000..bffa7e7ce0b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoint/version.go @@ -0,0 +1,10 @@ +package recoverypoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/recoverypoint/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/README.md new file mode 100644 index 00000000000..d982ce464fc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints` Documentation + +The `recoverypoints` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/recoverypoints" +``` + + +### Client Initialization + +```go +client := recoverypoints.NewRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointsClient.Get` + +```go +ctx := context.TODO() +id := recoverypoints.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + +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: `RecoveryPointsClient.List` + +```go +ctx := context.TODO() +id := recoverypoints.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + +// alternatively `client.List(ctx, id, recoverypoints.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, recoverypoints.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/client.go new file mode 100644 index 00000000000..dab85424069 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/client.go @@ -0,0 +1,18 @@ +package recoverypoints + +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 RecoveryPointsClient struct { + Client autorest.Client + baseUri string +} + +func NewRecoveryPointsClientWithBaseURI(endpoint string) RecoveryPointsClient { + return RecoveryPointsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/constants.go new file mode 100644 index 00000000000..5f51946c1d2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/constants.go @@ -0,0 +1,153 @@ +package recoverypoints + +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 RecoveryPointTierStatus string + +const ( + RecoveryPointTierStatusDeleted RecoveryPointTierStatus = "Deleted" + RecoveryPointTierStatusDisabled RecoveryPointTierStatus = "Disabled" + RecoveryPointTierStatusInvalid RecoveryPointTierStatus = "Invalid" + RecoveryPointTierStatusRehydrated RecoveryPointTierStatus = "Rehydrated" + RecoveryPointTierStatusValid RecoveryPointTierStatus = "Valid" +) + +func PossibleValuesForRecoveryPointTierStatus() []string { + return []string{ + string(RecoveryPointTierStatusDeleted), + string(RecoveryPointTierStatusDisabled), + string(RecoveryPointTierStatusInvalid), + string(RecoveryPointTierStatusRehydrated), + string(RecoveryPointTierStatusValid), + } +} + +func parseRecoveryPointTierStatus(input string) (*RecoveryPointTierStatus, error) { + vals := map[string]RecoveryPointTierStatus{ + "deleted": RecoveryPointTierStatusDeleted, + "disabled": RecoveryPointTierStatusDisabled, + "invalid": RecoveryPointTierStatusInvalid, + "rehydrated": RecoveryPointTierStatusRehydrated, + "valid": RecoveryPointTierStatusValid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierStatus(input) + return &out, nil +} + +type RecoveryPointTierType string + +const ( + RecoveryPointTierTypeArchivedRP RecoveryPointTierType = "ArchivedRP" + RecoveryPointTierTypeHardenedRP RecoveryPointTierType = "HardenedRP" + RecoveryPointTierTypeInstantRP RecoveryPointTierType = "InstantRP" + RecoveryPointTierTypeInvalid RecoveryPointTierType = "Invalid" +) + +func PossibleValuesForRecoveryPointTierType() []string { + return []string{ + string(RecoveryPointTierTypeArchivedRP), + string(RecoveryPointTierTypeHardenedRP), + string(RecoveryPointTierTypeInstantRP), + string(RecoveryPointTierTypeInvalid), + } +} + +func parseRecoveryPointTierType(input string) (*RecoveryPointTierType, error) { + vals := map[string]RecoveryPointTierType{ + "archivedrp": RecoveryPointTierTypeArchivedRP, + "hardenedrp": RecoveryPointTierTypeHardenedRP, + "instantrp": RecoveryPointTierTypeInstantRP, + "invalid": RecoveryPointTierTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierType(input) + return &out, nil +} + +type RestorePointType string + +const ( + RestorePointTypeDifferential RestorePointType = "Differential" + RestorePointTypeFull RestorePointType = "Full" + RestorePointTypeIncremental RestorePointType = "Incremental" + RestorePointTypeInvalid RestorePointType = "Invalid" + RestorePointTypeLog RestorePointType = "Log" + RestorePointTypeSnapshotCopyOnlyFull RestorePointType = "SnapshotCopyOnlyFull" + RestorePointTypeSnapshotFull RestorePointType = "SnapshotFull" +) + +func PossibleValuesForRestorePointType() []string { + return []string{ + string(RestorePointTypeDifferential), + string(RestorePointTypeFull), + string(RestorePointTypeIncremental), + string(RestorePointTypeInvalid), + string(RestorePointTypeLog), + string(RestorePointTypeSnapshotCopyOnlyFull), + string(RestorePointTypeSnapshotFull), + } +} + +func parseRestorePointType(input string) (*RestorePointType, error) { + vals := map[string]RestorePointType{ + "differential": RestorePointTypeDifferential, + "full": RestorePointTypeFull, + "incremental": RestorePointTypeIncremental, + "invalid": RestorePointTypeInvalid, + "log": RestorePointTypeLog, + "snapshotcopyonlyfull": RestorePointTypeSnapshotCopyOnlyFull, + "snapshotfull": RestorePointTypeSnapshotFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestorePointType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_protecteditem.go new file mode 100644 index 00000000000..415fce0b13f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_protecteditem.go @@ -0,0 +1,157 @@ +package recoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProtectedItemId{}) +} + +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) + } + + id := ProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := ProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_protecteditem_test.go new file mode 100644 index 00000000000..4d122dc61d0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_protecteditem_test.go @@ -0,0 +1,417 @@ +package recoverypoints + +import ( + "testing" + + "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{} + +func TestNewProtectedItemID(t *testing.T) { + id := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } + + if id.ProtectedItemName != "protectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemName") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestParseProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + ProtectedItemName: "pRoTeCtEdItEmNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestSegmentsForProtectedItemId(t *testing.T) { + segments := ProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_recoverypoint.go new file mode 100644 index 00000000000..3aa99fb455d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_recoverypoint.go @@ -0,0 +1,166 @@ +package recoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(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 := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemName"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointId"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) 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), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_recoverypoint_test.go new file mode 100644 index 00000000000..29d6cf0e70f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package recoverypoints + +import ( + "testing" + + "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 = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } + + if id.ProtectedItemName != "protectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemName") + } + + if id.RecoveryPointId != "recoveryPointId" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointId") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + RecoveryPointId: "recoveryPointId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + RecoveryPointId: "recoveryPointId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS/rEcOvErYpOiNtId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + ProtectedItemName: "pRoTeCtEdItEmNaMe", + RecoveryPointId: "rEcOvErYpOiNtId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS/rEcOvErYpOiNtId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/method_get_autorest.go new file mode 100644 index 00000000000..dce6d176011 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/method_get_autorest.go @@ -0,0 +1,68 @@ +package recoverypoints + +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 *RecoveryPointResource +} + +// Get ... +func (c RecoveryPointsClient) Get(ctx context.Context, id RecoveryPointId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c RecoveryPointsClient) preparerForGet(ctx context.Context, id RecoveryPointId) (*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 RecoveryPointsClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/method_list_autorest.go new file mode 100644 index 00000000000..904ef293b39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/method_list_autorest.go @@ -0,0 +1,215 @@ +package recoverypoints + +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 *[]RecoveryPointResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []RecoveryPointResource +} + +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 RecoveryPointsClient) List(ctx context.Context, id ProtectedItemId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c RecoveryPointsClient) preparerForList(ctx context.Context, id ProtectedItemId, 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/recoveryPoints", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c RecoveryPointsClient) 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 RecoveryPointsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []RecoveryPointResource `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, "recoverypoints.RecoveryPointsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c RecoveryPointsClient) ListComplete(ctx context.Context, id ProtectedItemId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, RecoveryPointResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RecoveryPointsClient) ListCompleteMatchingPredicate(ctx context.Context, id ProtectedItemId, options ListOperationOptions, predicate RecoveryPointResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]RecoveryPointResource, 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/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azurefilesharerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azurefilesharerecoverypoint.go new file mode 100644 index 00000000000..9c6d8e1fff7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azurefilesharerecoverypoint.go @@ -0,0 +1,54 @@ +package recoverypoints + +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 _ RecoveryPoint = AzureFileShareRecoveryPoint{} + +type AzureFileShareRecoveryPoint struct { + FileShareSnapshotUri *string `json:"fileShareSnapshotUri,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointSizeInGB *int64 `json:"recoveryPointSizeInGB,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureFileShareRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureFileShareRecoveryPoint{} + +func (s AzureFileShareRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureFileShareRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go new file mode 100644 index 00000000000..3dfada645a6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go @@ -0,0 +1,55 @@ +package recoverypoints + +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 _ RecoveryPoint = AzureWorkloadPointInTimeRecoveryPoint{} + +type AzureWorkloadPointInTimeRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadPointInTimeRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRecoveryPoint{} + +func (s AzureWorkloadPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadrecoverypoint.go new file mode 100644 index 00000000000..c8130692c90 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadrecoverypoint.go @@ -0,0 +1,54 @@ +package recoverypoints + +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 _ RecoveryPoint = AzureWorkloadRecoveryPoint{} + +type AzureWorkloadRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadRecoveryPoint{} + +func (s AzureWorkloadRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go new file mode 100644 index 00000000000..f506c124c38 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go @@ -0,0 +1,55 @@ +package recoverypoints + +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 _ RecoveryPoint = AzureWorkloadSAPHanaPointInTimeRecoveryPoint{} + +type AzureWorkloadSAPHanaPointInTimeRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadSAPHanaPointInTimeRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRecoveryPoint{} + +func (s AzureWorkloadSAPHanaPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go new file mode 100644 index 00000000000..923688f5266 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go @@ -0,0 +1,54 @@ +package recoverypoints + +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 _ RecoveryPoint = AzureWorkloadSAPHanaRecoveryPoint{} + +type AzureWorkloadSAPHanaRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadSAPHanaRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRecoveryPoint{} + +func (s AzureWorkloadSAPHanaRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go new file mode 100644 index 00000000000..f513a0708c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go @@ -0,0 +1,56 @@ +package recoverypoints + +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 _ RecoveryPoint = AzureWorkloadSQLPointInTimeRecoveryPoint{} + +type AzureWorkloadSQLPointInTimeRecoveryPoint struct { + ExtendedInfo *AzureWorkloadSQLRecoveryPointExtendedInfo `json:"extendedInfo,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadSQLPointInTimeRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRecoveryPoint{} + +func (s AzureWorkloadSQLPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go new file mode 100644 index 00000000000..d929dddcdea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go @@ -0,0 +1,55 @@ +package recoverypoints + +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 _ RecoveryPoint = AzureWorkloadSQLRecoveryPoint{} + +type AzureWorkloadSQLRecoveryPoint struct { + ExtendedInfo *AzureWorkloadSQLRecoveryPointExtendedInfo `json:"extendedInfo,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadSQLRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadSQLRecoveryPoint{} + +func (s AzureWorkloadSQLRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go new file mode 100644 index 00000000000..8ad178eb3ba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go @@ -0,0 +1,27 @@ +package recoverypoints + +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 AzureWorkloadSQLRecoveryPointExtendedInfo struct { + DataDirectoryPaths *[]SQLDataDirectory `json:"dataDirectoryPaths,omitempty"` + DataDirectoryTimeInUTC *string `json:"dataDirectoryTimeInUTC,omitempty"` +} + +func (o *AzureWorkloadSQLRecoveryPointExtendedInfo) GetDataDirectoryTimeInUTCAsTime() (*time.Time, error) { + if o.DataDirectoryTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DataDirectoryTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadSQLRecoveryPointExtendedInfo) SetDataDirectoryTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DataDirectoryTimeInUTC = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_bekdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_bekdetails.go new file mode 100644 index 00000000000..66e779c1d33 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_bekdetails.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BEKDetails struct { + SecretData *string `json:"secretData,omitempty"` + SecretURL *string `json:"secretUrl,omitempty"` + SecretVaultId *string `json:"secretVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_diskinformation.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_diskinformation.go new file mode 100644 index 00000000000..1d6ed082bf4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_diskinformation.go @@ -0,0 +1,9 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskInformation struct { + Lun *int64 `json:"lun,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_extendedlocation.go new file mode 100644 index 00000000000..a4b7423fd00 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_extendedlocation.go @@ -0,0 +1,9 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_genericrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_genericrecoverypoint.go new file mode 100644 index 00000000000..c042f5d3458 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_genericrecoverypoint.go @@ -0,0 +1,54 @@ +package recoverypoints + +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 _ RecoveryPoint = GenericRecoveryPoint{} + +type GenericRecoveryPoint struct { + FriendlyName *string `json:"friendlyName,omitempty"` + RecoveryPointAdditionalInfo *string `json:"recoveryPointAdditionalInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s GenericRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = GenericRecoveryPoint{} + +func (s GenericRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper GenericRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "GenericRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_iaasvmrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_iaasvmrecoverypoint.go new file mode 100644 index 00000000000..ec166e8cd93 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_iaasvmrecoverypoint.go @@ -0,0 +1,70 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = IaasVMRecoveryPoint{} + +type IaasVMRecoveryPoint struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IsInstantIlrSessionActive *bool `json:"isInstantIlrSessionActive,omitempty"` + IsManagedVirtualMachine *bool `json:"isManagedVirtualMachine,omitempty"` + IsPrivateAccessEnabledOnAnyDisk *bool `json:"isPrivateAccessEnabledOnAnyDisk,omitempty"` + IsSourceVMEncrypted *bool `json:"isSourceVMEncrypted,omitempty"` + KeyAndSecret *KeyAndSecretDetails `json:"keyAndSecret,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + OsType *string `json:"osType,omitempty"` + RecoveryPointAdditionalInfo *string `json:"recoveryPointAdditionalInfo,omitempty"` + RecoveryPointDiskConfiguration *RecoveryPointDiskConfiguration `json:"recoveryPointDiskConfiguration,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + SecurityType *string `json:"securityType,omitempty"` + SourceVMStorageType *string `json:"sourceVMStorageType,omitempty"` + VirtualMachineSize *string `json:"virtualMachineSize,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s IaasVMRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = IaasVMRecoveryPoint{} + +func (s IaasVMRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "IaasVMRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_kekdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_kekdetails.go new file mode 100644 index 00000000000..500357083c8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_kekdetails.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KEKDetails struct { + KeyBackupData *string `json:"keyBackupData,omitempty"` + KeyURL *string `json:"keyUrl,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_keyandsecretdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_keyandsecretdetails.go new file mode 100644 index 00000000000..96c513fc516 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_keyandsecretdetails.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyAndSecretDetails struct { + BekDetails *BEKDetails `json:"bekDetails,omitempty"` + EncryptionMechanism *string `json:"encryptionMechanism,omitempty"` + KekDetails *KEKDetails `json:"kekDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_pointintimerange.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_pointintimerange.go new file mode 100644 index 00000000000..4190258e022 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_pointintimerange.go @@ -0,0 +1,39 @@ +package recoverypoints + +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 PointInTimeRange struct { + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *PointInTimeRange) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PointInTimeRange) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PointInTimeRange) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PointInTimeRange) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypoint.go new file mode 100644 index 00000000000..2436345bee3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypoint.go @@ -0,0 +1,139 @@ +package recoverypoints + +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 RecoveryPoint interface { + RecoveryPoint() BaseRecoveryPointImpl +} + +var _ RecoveryPoint = BaseRecoveryPointImpl{} + +type BaseRecoveryPointImpl struct { + ObjectType string `json:"objectType"` +} + +func (s BaseRecoveryPointImpl) RecoveryPoint() BaseRecoveryPointImpl { + return s +} + +var _ RecoveryPoint = RawRecoveryPointImpl{} + +// RawRecoveryPointImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRecoveryPointImpl struct { + recoveryPoint BaseRecoveryPointImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPointImpl) RecoveryPoint() BaseRecoveryPointImpl { + return s.recoveryPoint +} + +func UnmarshalRecoveryPointImplementation(input []byte) (RecoveryPoint, 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 RecoveryPoint into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureFileShareRecoveryPoint") { + var out AzureFileShareRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRecoveryPoint") { + var out AzureWorkloadPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRecoveryPoint") { + var out AzureWorkloadRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRecoveryPoint") { + var out AzureWorkloadSAPHanaPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRecoveryPoint") { + var out AzureWorkloadSAPHanaRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRecoveryPoint") { + var out AzureWorkloadSQLPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRecoveryPoint") { + var out AzureWorkloadSQLRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericRecoveryPoint") { + var out GenericRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRecoveryPoint") { + var out IaasVMRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRecoveryPoint: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPointImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPointImpl: %+v", err) + } + + return RawRecoveryPointImpl{ + recoveryPoint: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointdiskconfiguration.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointdiskconfiguration.go new file mode 100644 index 00000000000..d3935380d03 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointdiskconfiguration.go @@ -0,0 +1,11 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointDiskConfiguration struct { + ExcludedDiskList *[]DiskInformation `json:"excludedDiskList,omitempty"` + IncludedDiskList *[]DiskInformation `json:"includedDiskList,omitempty"` + NumberOfDisksAttachedToVM *int64 `json:"numberOfDisksAttachedToVm,omitempty"` + NumberOfDisksIncludedInBackup *int64 `json:"numberOfDisksIncludedInBackup,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointmovereadinessinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointmovereadinessinfo.go new file mode 100644 index 00000000000..03cab067198 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointmovereadinessinfo.go @@ -0,0 +1,9 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointMoveReadinessInfo struct { + AdditionalInfo *string `json:"additionalInfo,omitempty"` + IsReadyForMove *bool `json:"isReadyForMove,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointproperties.go new file mode 100644 index 00000000000..4bd3f5e75a3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointproperties.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointProperties struct { + ExpiryTime *string `json:"expiryTime,omitempty"` + IsSoftDeleted *bool `json:"isSoftDeleted,omitempty"` + RuleName *string `json:"ruleName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointresource.go new file mode 100644 index 00000000000..b5dfebfca85 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointresource.go @@ -0,0 +1,57 @@ +package recoverypoints + +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 RecoveryPointResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties RecoveryPoint `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPointResource{} + +func (s *RecoveryPointResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 RecoveryPointResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalRecoveryPointImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'RecoveryPointResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointtierinformationv2.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointtierinformationv2.go new file mode 100644 index 00000000000..996285f0562 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_recoverypointtierinformationv2.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointTierInformationV2 struct { + ExtendedInfo *map[string]string `json:"extendedInfo,omitempty"` + Status *RecoveryPointTierStatus `json:"status,omitempty"` + Type *RecoveryPointTierType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_sqldatadirectory.go new file mode 100644 index 00000000000..8460946fc57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/model_sqldatadirectory.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectory struct { + LogicalName *string `json:"logicalName,omitempty"` + Path *string `json:"path,omitempty"` + Type *SQLDataDirectoryType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/predicates.go new file mode 100644 index 00000000000..c3db33a5e75 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/predicates.go @@ -0,0 +1,37 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPointResourceOperationPredicate) Matches(input RecoveryPointResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/version.go new file mode 100644 index 00000000000..0e706ef7a72 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypoints/version.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/recoverypoints/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/README.md new file mode 100644 index 00000000000..26ad692e301 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove` Documentation + +The `recoverypointsrecommendedformove` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/recoverypointsrecommendedformove" +``` + + +### Client Initialization + +```go +client := recoverypointsrecommendedformove.NewRecoveryPointsRecommendedForMoveClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointsRecommendedForMoveClient.List` + +```go +ctx := context.TODO() +id := recoverypointsrecommendedformove.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + +payload := recoverypointsrecommendedformove.ListRecoveryPointsRecommendedForMoveRequest{ + // ... +} + + +// alternatively `client.List(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/client.go new file mode 100644 index 00000000000..0f891c24f9b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/client.go @@ -0,0 +1,18 @@ +package recoverypointsrecommendedformove + +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 RecoveryPointsRecommendedForMoveClient struct { + Client autorest.Client + baseUri string +} + +func NewRecoveryPointsRecommendedForMoveClientWithBaseURI(endpoint string) RecoveryPointsRecommendedForMoveClient { + return RecoveryPointsRecommendedForMoveClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/constants.go new file mode 100644 index 00000000000..fb82375e57a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/constants.go @@ -0,0 +1,153 @@ +package recoverypointsrecommendedformove + +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 RecoveryPointTierStatus string + +const ( + RecoveryPointTierStatusDeleted RecoveryPointTierStatus = "Deleted" + RecoveryPointTierStatusDisabled RecoveryPointTierStatus = "Disabled" + RecoveryPointTierStatusInvalid RecoveryPointTierStatus = "Invalid" + RecoveryPointTierStatusRehydrated RecoveryPointTierStatus = "Rehydrated" + RecoveryPointTierStatusValid RecoveryPointTierStatus = "Valid" +) + +func PossibleValuesForRecoveryPointTierStatus() []string { + return []string{ + string(RecoveryPointTierStatusDeleted), + string(RecoveryPointTierStatusDisabled), + string(RecoveryPointTierStatusInvalid), + string(RecoveryPointTierStatusRehydrated), + string(RecoveryPointTierStatusValid), + } +} + +func parseRecoveryPointTierStatus(input string) (*RecoveryPointTierStatus, error) { + vals := map[string]RecoveryPointTierStatus{ + "deleted": RecoveryPointTierStatusDeleted, + "disabled": RecoveryPointTierStatusDisabled, + "invalid": RecoveryPointTierStatusInvalid, + "rehydrated": RecoveryPointTierStatusRehydrated, + "valid": RecoveryPointTierStatusValid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierStatus(input) + return &out, nil +} + +type RecoveryPointTierType string + +const ( + RecoveryPointTierTypeArchivedRP RecoveryPointTierType = "ArchivedRP" + RecoveryPointTierTypeHardenedRP RecoveryPointTierType = "HardenedRP" + RecoveryPointTierTypeInstantRP RecoveryPointTierType = "InstantRP" + RecoveryPointTierTypeInvalid RecoveryPointTierType = "Invalid" +) + +func PossibleValuesForRecoveryPointTierType() []string { + return []string{ + string(RecoveryPointTierTypeArchivedRP), + string(RecoveryPointTierTypeHardenedRP), + string(RecoveryPointTierTypeInstantRP), + string(RecoveryPointTierTypeInvalid), + } +} + +func parseRecoveryPointTierType(input string) (*RecoveryPointTierType, error) { + vals := map[string]RecoveryPointTierType{ + "archivedrp": RecoveryPointTierTypeArchivedRP, + "hardenedrp": RecoveryPointTierTypeHardenedRP, + "instantrp": RecoveryPointTierTypeInstantRP, + "invalid": RecoveryPointTierTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierType(input) + return &out, nil +} + +type RestorePointType string + +const ( + RestorePointTypeDifferential RestorePointType = "Differential" + RestorePointTypeFull RestorePointType = "Full" + RestorePointTypeIncremental RestorePointType = "Incremental" + RestorePointTypeInvalid RestorePointType = "Invalid" + RestorePointTypeLog RestorePointType = "Log" + RestorePointTypeSnapshotCopyOnlyFull RestorePointType = "SnapshotCopyOnlyFull" + RestorePointTypeSnapshotFull RestorePointType = "SnapshotFull" +) + +func PossibleValuesForRestorePointType() []string { + return []string{ + string(RestorePointTypeDifferential), + string(RestorePointTypeFull), + string(RestorePointTypeIncremental), + string(RestorePointTypeInvalid), + string(RestorePointTypeLog), + string(RestorePointTypeSnapshotCopyOnlyFull), + string(RestorePointTypeSnapshotFull), + } +} + +func parseRestorePointType(input string) (*RestorePointType, error) { + vals := map[string]RestorePointType{ + "differential": RestorePointTypeDifferential, + "full": RestorePointTypeFull, + "incremental": RestorePointTypeIncremental, + "invalid": RestorePointTypeInvalid, + "log": RestorePointTypeLog, + "snapshotcopyonlyfull": RestorePointTypeSnapshotCopyOnlyFull, + "snapshotfull": RestorePointTypeSnapshotFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestorePointType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/id_protecteditem.go new file mode 100644 index 00000000000..de5eadab57a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/id_protecteditem.go @@ -0,0 +1,157 @@ +package recoverypointsrecommendedformove + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProtectedItemId{}) +} + +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) + } + + id := ProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := ProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + return 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/id_protecteditem_test.go new file mode 100644 index 00000000000..9418ddc0c75 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/id_protecteditem_test.go @@ -0,0 +1,417 @@ +package recoverypointsrecommendedformove + +import ( + "testing" + + "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{} + +func TestNewProtectedItemID(t *testing.T) { + id := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } + + if id.ProtectedItemName != "protectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemName") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestParseProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + ProtectedItemName: "pRoTeCtEdItEmNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestSegmentsForProtectedItemId(t *testing.T) { + segments := ProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/method_list_autorest.go new file mode 100644 index 00000000000..71847a51411 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/method_list_autorest.go @@ -0,0 +1,187 @@ +package recoverypointsrecommendedformove + +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 *[]RecoveryPointResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []RecoveryPointResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// List ... +func (c RecoveryPointsRecommendedForMoveClient) List(ctx context.Context, id ProtectedItemId, input ListRecoveryPointsRecommendedForMoveRequest) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c RecoveryPointsRecommendedForMoveClient) preparerForList(ctx context.Context, id ProtectedItemId, input ListRecoveryPointsRecommendedForMoveRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/recoveryPointsRecommendedForMove", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c RecoveryPointsRecommendedForMoveClient) 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.AsPost(), + 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 RecoveryPointsRecommendedForMoveClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []RecoveryPointResource `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, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c RecoveryPointsRecommendedForMoveClient) ListComplete(ctx context.Context, id ProtectedItemId, input ListRecoveryPointsRecommendedForMoveRequest) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, input, RecoveryPointResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RecoveryPointsRecommendedForMoveClient) ListCompleteMatchingPredicate(ctx context.Context, id ProtectedItemId, input ListRecoveryPointsRecommendedForMoveRequest, predicate RecoveryPointResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]RecoveryPointResource, 0) + + page, err := c.List(ctx, id, input) + 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/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go new file mode 100644 index 00000000000..30e5b883f9a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go @@ -0,0 +1,54 @@ +package recoverypointsrecommendedformove + +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 _ RecoveryPoint = AzureFileShareRecoveryPoint{} + +type AzureFileShareRecoveryPoint struct { + FileShareSnapshotUri *string `json:"fileShareSnapshotUri,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointSizeInGB *int64 `json:"recoveryPointSizeInGB,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureFileShareRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureFileShareRecoveryPoint{} + +func (s AzureFileShareRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureFileShareRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go new file mode 100644 index 00000000000..c03b22f00e3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go @@ -0,0 +1,55 @@ +package recoverypointsrecommendedformove + +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 _ RecoveryPoint = AzureWorkloadPointInTimeRecoveryPoint{} + +type AzureWorkloadPointInTimeRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadPointInTimeRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRecoveryPoint{} + +func (s AzureWorkloadPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go new file mode 100644 index 00000000000..9d2d7ab7f51 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go @@ -0,0 +1,54 @@ +package recoverypointsrecommendedformove + +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 _ RecoveryPoint = AzureWorkloadRecoveryPoint{} + +type AzureWorkloadRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadRecoveryPoint{} + +func (s AzureWorkloadRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go new file mode 100644 index 00000000000..9656d66df24 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go @@ -0,0 +1,55 @@ +package recoverypointsrecommendedformove + +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 _ RecoveryPoint = AzureWorkloadSAPHanaPointInTimeRecoveryPoint{} + +type AzureWorkloadSAPHanaPointInTimeRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadSAPHanaPointInTimeRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRecoveryPoint{} + +func (s AzureWorkloadSAPHanaPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go new file mode 100644 index 00000000000..e0f1dcb3628 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go @@ -0,0 +1,54 @@ +package recoverypointsrecommendedformove + +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 _ RecoveryPoint = AzureWorkloadSAPHanaRecoveryPoint{} + +type AzureWorkloadSAPHanaRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadSAPHanaRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRecoveryPoint{} + +func (s AzureWorkloadSAPHanaRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go new file mode 100644 index 00000000000..0a959291b09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go @@ -0,0 +1,56 @@ +package recoverypointsrecommendedformove + +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 _ RecoveryPoint = AzureWorkloadSQLPointInTimeRecoveryPoint{} + +type AzureWorkloadSQLPointInTimeRecoveryPoint struct { + ExtendedInfo *AzureWorkloadSQLRecoveryPointExtendedInfo `json:"extendedInfo,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadSQLPointInTimeRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRecoveryPoint{} + +func (s AzureWorkloadSQLPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go new file mode 100644 index 00000000000..007f0e44d47 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go @@ -0,0 +1,55 @@ +package recoverypointsrecommendedformove + +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 _ RecoveryPoint = AzureWorkloadSQLRecoveryPoint{} + +type AzureWorkloadSQLRecoveryPoint struct { + ExtendedInfo *AzureWorkloadSQLRecoveryPointExtendedInfo `json:"extendedInfo,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s AzureWorkloadSQLRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = AzureWorkloadSQLRecoveryPoint{} + +func (s AzureWorkloadSQLRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go new file mode 100644 index 00000000000..f98b9b7a0b4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go @@ -0,0 +1,27 @@ +package recoverypointsrecommendedformove + +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 AzureWorkloadSQLRecoveryPointExtendedInfo struct { + DataDirectoryPaths *[]SQLDataDirectory `json:"dataDirectoryPaths,omitempty"` + DataDirectoryTimeInUTC *string `json:"dataDirectoryTimeInUTC,omitempty"` +} + +func (o *AzureWorkloadSQLRecoveryPointExtendedInfo) GetDataDirectoryTimeInUTCAsTime() (*time.Time, error) { + if o.DataDirectoryTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DataDirectoryTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadSQLRecoveryPointExtendedInfo) SetDataDirectoryTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DataDirectoryTimeInUTC = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_bekdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_bekdetails.go new file mode 100644 index 00000000000..d27d63b2bdb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_bekdetails.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BEKDetails struct { + SecretData *string `json:"secretData,omitempty"` + SecretURL *string `json:"secretUrl,omitempty"` + SecretVaultId *string `json:"secretVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_diskinformation.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_diskinformation.go new file mode 100644 index 00000000000..efce1750999 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_diskinformation.go @@ -0,0 +1,9 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskInformation struct { + Lun *int64 `json:"lun,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_extendedlocation.go new file mode 100644 index 00000000000..04a4089410d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_extendedlocation.go @@ -0,0 +1,9 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go new file mode 100644 index 00000000000..9d60f19a2cb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go @@ -0,0 +1,54 @@ +package recoverypointsrecommendedformove + +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 _ RecoveryPoint = GenericRecoveryPoint{} + +type GenericRecoveryPoint struct { + FriendlyName *string `json:"friendlyName,omitempty"` + RecoveryPointAdditionalInfo *string `json:"recoveryPointAdditionalInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s GenericRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = GenericRecoveryPoint{} + +func (s GenericRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper GenericRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "GenericRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go new file mode 100644 index 00000000000..4bc19438a4e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go @@ -0,0 +1,70 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = IaasVMRecoveryPoint{} + +type IaasVMRecoveryPoint struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IsInstantIlrSessionActive *bool `json:"isInstantIlrSessionActive,omitempty"` + IsManagedVirtualMachine *bool `json:"isManagedVirtualMachine,omitempty"` + IsPrivateAccessEnabledOnAnyDisk *bool `json:"isPrivateAccessEnabledOnAnyDisk,omitempty"` + IsSourceVMEncrypted *bool `json:"isSourceVMEncrypted,omitempty"` + KeyAndSecret *KeyAndSecretDetails `json:"keyAndSecret,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + OsType *string `json:"osType,omitempty"` + RecoveryPointAdditionalInfo *string `json:"recoveryPointAdditionalInfo,omitempty"` + RecoveryPointDiskConfiguration *RecoveryPointDiskConfiguration `json:"recoveryPointDiskConfiguration,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + SecurityType *string `json:"securityType,omitempty"` + SourceVMStorageType *string `json:"sourceVMStorageType,omitempty"` + VirtualMachineSize *string `json:"virtualMachineSize,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RecoveryPoint + + ObjectType string `json:"objectType"` +} + +func (s IaasVMRecoveryPoint) RecoveryPoint() BaseRecoveryPointImpl { + return BaseRecoveryPointImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = IaasVMRecoveryPoint{} + +func (s IaasVMRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRecoveryPoint: %+v", err) + } + + decoded["objectType"] = "IaasVMRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_kekdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_kekdetails.go new file mode 100644 index 00000000000..4c54e953bf4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_kekdetails.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KEKDetails struct { + KeyBackupData *string `json:"keyBackupData,omitempty"` + KeyURL *string `json:"keyUrl,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go new file mode 100644 index 00000000000..65444fc0f49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyAndSecretDetails struct { + BekDetails *BEKDetails `json:"bekDetails,omitempty"` + EncryptionMechanism *string `json:"encryptionMechanism,omitempty"` + KekDetails *KEKDetails `json:"kekDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go new file mode 100644 index 00000000000..0085a2a3b9d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go @@ -0,0 +1,9 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRecoveryPointsRecommendedForMoveRequest struct { + ExcludedRPList *[]string `json:"excludedRPList,omitempty"` + ObjectType *string `json:"objectType,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_pointintimerange.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_pointintimerange.go new file mode 100644 index 00000000000..9bb33473707 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_pointintimerange.go @@ -0,0 +1,39 @@ +package recoverypointsrecommendedformove + +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 PointInTimeRange struct { + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *PointInTimeRange) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PointInTimeRange) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PointInTimeRange) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PointInTimeRange) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypoint.go new file mode 100644 index 00000000000..947d1e7488b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypoint.go @@ -0,0 +1,139 @@ +package recoverypointsrecommendedformove + +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 RecoveryPoint interface { + RecoveryPoint() BaseRecoveryPointImpl +} + +var _ RecoveryPoint = BaseRecoveryPointImpl{} + +type BaseRecoveryPointImpl struct { + ObjectType string `json:"objectType"` +} + +func (s BaseRecoveryPointImpl) RecoveryPoint() BaseRecoveryPointImpl { + return s +} + +var _ RecoveryPoint = RawRecoveryPointImpl{} + +// RawRecoveryPointImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRecoveryPointImpl struct { + recoveryPoint BaseRecoveryPointImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPointImpl) RecoveryPoint() BaseRecoveryPointImpl { + return s.recoveryPoint +} + +func UnmarshalRecoveryPointImplementation(input []byte) (RecoveryPoint, 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 RecoveryPoint into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureFileShareRecoveryPoint") { + var out AzureFileShareRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRecoveryPoint") { + var out AzureWorkloadPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRecoveryPoint") { + var out AzureWorkloadRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRecoveryPoint") { + var out AzureWorkloadSAPHanaPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRecoveryPoint") { + var out AzureWorkloadSAPHanaRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRecoveryPoint") { + var out AzureWorkloadSQLPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRecoveryPoint") { + var out AzureWorkloadSQLRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericRecoveryPoint") { + var out GenericRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRecoveryPoint") { + var out IaasVMRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRecoveryPoint: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPointImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPointImpl: %+v", err) + } + + return RawRecoveryPointImpl{ + recoveryPoint: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go new file mode 100644 index 00000000000..6ec831b050f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go @@ -0,0 +1,11 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointDiskConfiguration struct { + ExcludedDiskList *[]DiskInformation `json:"excludedDiskList,omitempty"` + IncludedDiskList *[]DiskInformation `json:"includedDiskList,omitempty"` + NumberOfDisksAttachedToVM *int64 `json:"numberOfDisksAttachedToVm,omitempty"` + NumberOfDisksIncludedInBackup *int64 `json:"numberOfDisksIncludedInBackup,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go new file mode 100644 index 00000000000..2f638ab7bcd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go @@ -0,0 +1,9 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointMoveReadinessInfo struct { + AdditionalInfo *string `json:"additionalInfo,omitempty"` + IsReadyForMove *bool `json:"isReadyForMove,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointproperties.go new file mode 100644 index 00000000000..97af2516cec --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointproperties.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointProperties struct { + ExpiryTime *string `json:"expiryTime,omitempty"` + IsSoftDeleted *bool `json:"isSoftDeleted,omitempty"` + RuleName *string `json:"ruleName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointresource.go new file mode 100644 index 00000000000..55de0ec114d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointresource.go @@ -0,0 +1,57 @@ +package recoverypointsrecommendedformove + +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 RecoveryPointResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties RecoveryPoint `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPointResource{} + +func (s *RecoveryPointResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 RecoveryPointResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalRecoveryPointImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'RecoveryPointResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go new file mode 100644 index 00000000000..6f014df3e1d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointTierInformationV2 struct { + ExtendedInfo *map[string]string `json:"extendedInfo,omitempty"` + Status *RecoveryPointTierStatus `json:"status,omitempty"` + Type *RecoveryPointTierType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_sqldatadirectory.go new file mode 100644 index 00000000000..74ae63ba5e5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/model_sqldatadirectory.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectory struct { + LogicalName *string `json:"logicalName,omitempty"` + Path *string `json:"path,omitempty"` + Type *SQLDataDirectoryType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/predicates.go new file mode 100644 index 00000000000..9f73792f14b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/predicates.go @@ -0,0 +1,37 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPointResourceOperationPredicate) Matches(input RecoveryPointResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/version.go new file mode 100644 index 00000000000..c9841c6b334 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/recoverypointsrecommendedformove/version.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/recoverypointsrecommendedformove/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/README.md new file mode 100644 index 00000000000..b080a457104 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies` Documentation + +The `resourceguardproxies` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/resourceguardproxies" +``` + + +### Client Initialization + +```go +client := resourceguardproxies.NewResourceGuardProxiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceGuardProxiesClient.Get` + +```go +ctx := context.TODO() +id := resourceguardproxies.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.Get(ctx, id)` can be used to do batched pagination +items, err := client.GetComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/client.go new file mode 100644 index 00000000000..ad46ba07081 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/client.go @@ -0,0 +1,18 @@ +package resourceguardproxies + +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 ResourceGuardProxiesClient struct { + Client autorest.Client + baseUri string +} + +func NewResourceGuardProxiesClientWithBaseURI(endpoint string) ResourceGuardProxiesClient { + return ResourceGuardProxiesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/id_vault.go new file mode 100644 index 00000000000..8e0a2465576 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/id_vault.go @@ -0,0 +1,130 @@ +package resourceguardproxies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/id_vault_test.go new file mode 100644 index 00000000000..3a091dac527 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/id_vault_test.go @@ -0,0 +1,282 @@ +package resourceguardproxies + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/method_get_autorest.go new file mode 100644 index 00000000000..d7c440b262d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/method_get_autorest.go @@ -0,0 +1,186 @@ +package resourceguardproxies + +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 GetOperationResponse struct { + HttpResponse *http.Response + Model *[]ResourceGuardProxyBaseResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (GetOperationResponse, error) +} + +type GetCompleteResult struct { + Items []ResourceGuardProxyBaseResource +} + +func (r GetOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r GetOperationResponse) LoadMore(ctx context.Context) (resp GetOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// Get ... +func (c ResourceGuardProxiesClient) Get(ctx context.Context, id VaultId) (resp GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForGet(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForGet prepares the Get request. +func (c ResourceGuardProxiesClient) preparerForGet(ctx context.Context, id VaultId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupResourceGuardProxies", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForGetWithNextLink prepares the Get request with the given nextLink token. +func (c ResourceGuardProxiesClient) preparerForGetWithNextLink(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)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxiesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + type page struct { + Values []ResourceGuardProxyBaseResource `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 GetOperationResponse, err error) { + req, err := c.preparerForGetWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// GetComplete retrieves all of the results into a single object +func (c ResourceGuardProxiesClient) GetComplete(ctx context.Context, id VaultId) (GetCompleteResult, error) { + return c.GetCompleteMatchingPredicate(ctx, id, ResourceGuardProxyBaseResourceOperationPredicate{}) +} + +// GetCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ResourceGuardProxiesClient) GetCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate ResourceGuardProxyBaseResourceOperationPredicate) (resp GetCompleteResult, err error) { + items := make([]ResourceGuardProxyBaseResource, 0) + + page, err := c.Get(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := GetCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardoperationdetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardoperationdetail.go new file mode 100644 index 00000000000..fedeee2c425 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardoperationdetail.go @@ -0,0 +1,9 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardOperationDetail struct { + DefaultResourceRequest *string `json:"defaultResourceRequest,omitempty"` + VaultCriticalOperation *string `json:"vaultCriticalOperation,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardproxybase.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardproxybase.go new file mode 100644 index 00000000000..26938a5027c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardproxybase.go @@ -0,0 +1,11 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBase struct { + Description *string `json:"description,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + ResourceGuardOperationDetails *[]ResourceGuardOperationDetail `json:"resourceGuardOperationDetails,omitempty"` + ResourceGuardResourceId string `json:"resourceGuardResourceId"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardproxybaseresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardproxybaseresource.go new file mode 100644 index 00000000000..bc307c162c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/model_resourceguardproxybaseresource.go @@ -0,0 +1,14 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceGuardProxyBase `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/predicates.go new file mode 100644 index 00000000000..dca1b113f34 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/predicates.go @@ -0,0 +1,37 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ResourceGuardProxyBaseResourceOperationPredicate) Matches(input ResourceGuardProxyBaseResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/version.go new file mode 100644 index 00000000000..e5517871646 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxies/version.go @@ -0,0 +1,10 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resourceguardproxies/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/README.md new file mode 100644 index 00000000000..14a7b298766 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/README.md @@ -0,0 +1,94 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy` Documentation + +The `resourceguardproxy` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/resourceguardproxy" +``` + + +### Client Initialization + +```go +client := resourceguardproxy.NewResourceGuardProxyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceGuardProxyClient.Delete` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupResourceGuardProxyName") + +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: `ResourceGuardProxyClient.Get` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupResourceGuardProxyName") + +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: `ResourceGuardProxyClient.Put` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupResourceGuardProxyName") + +payload := resourceguardproxy.ResourceGuardProxyBaseResource{ + // ... +} + + +read, err := client.Put(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardProxyClient.UnlockDelete` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupResourceGuardProxyName") + +payload := resourceguardproxy.UnlockDeleteRequest{ + // ... +} + + +read, err := client.UnlockDelete(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/client.go new file mode 100644 index 00000000000..d07fa6e5381 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/client.go @@ -0,0 +1,18 @@ +package resourceguardproxy + +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 ResourceGuardProxyClient struct { + Client autorest.Client + baseUri string +} + +func NewResourceGuardProxyClientWithBaseURI(endpoint string) ResourceGuardProxyClient { + return ResourceGuardProxyClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/id_backupresourceguardproxy.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/id_backupresourceguardproxy.go new file mode 100644 index 00000000000..0b39ee42460 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/id_backupresourceguardproxy.go @@ -0,0 +1,139 @@ +package resourceguardproxy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupResourceGuardProxyId{}) +} + +var _ resourceids.ResourceId = &BackupResourceGuardProxyId{} + +// BackupResourceGuardProxyId is a struct representing the Resource ID for a Backup Resource Guard Proxy +type BackupResourceGuardProxyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupResourceGuardProxyName string +} + +// NewBackupResourceGuardProxyID returns a new BackupResourceGuardProxyId struct +func NewBackupResourceGuardProxyID(subscriptionId string, resourceGroupName string, vaultName string, backupResourceGuardProxyName string) BackupResourceGuardProxyId { + return BackupResourceGuardProxyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupResourceGuardProxyName: backupResourceGuardProxyName, + } +} + +// ParseBackupResourceGuardProxyID parses 'input' into a BackupResourceGuardProxyId +func ParseBackupResourceGuardProxyID(input string) (*BackupResourceGuardProxyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupResourceGuardProxyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupResourceGuardProxyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupResourceGuardProxyIDInsensitively parses 'input' case-insensitively into a BackupResourceGuardProxyId +// note: this method should only be used for API response data and not user input +func ParseBackupResourceGuardProxyIDInsensitively(input string) (*BackupResourceGuardProxyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupResourceGuardProxyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupResourceGuardProxyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupResourceGuardProxyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupResourceGuardProxyName, ok = input.Parsed["backupResourceGuardProxyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupResourceGuardProxyName", input) + } + + return nil +} + +// ValidateBackupResourceGuardProxyID checks that 'input' can be parsed as a Backup Resource Guard Proxy ID +func ValidateBackupResourceGuardProxyID(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 := ParseBackupResourceGuardProxyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupResourceGuardProxies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupResourceGuardProxyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupResourceGuardProxies", "backupResourceGuardProxies", "backupResourceGuardProxies"), + resourceids.UserSpecifiedSegment("backupResourceGuardProxyName", "backupResourceGuardProxyName"), + } +} + +// String returns a human-readable description of this Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) 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 Resource Guard Proxy Name: %q", id.BackupResourceGuardProxyName), + } + return fmt.Sprintf("Backup Resource Guard Proxy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/id_backupresourceguardproxy_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/id_backupresourceguardproxy_test.go new file mode 100644 index 00000000000..f1e9dde384a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/id_backupresourceguardproxy_test.go @@ -0,0 +1,327 @@ +package resourceguardproxy + +import ( + "testing" + + "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 = &BackupResourceGuardProxyId{} + +func TestNewBackupResourceGuardProxyID(t *testing.T) { + id := NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupResourceGuardProxyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupResourceGuardProxyName != "backupResourceGuardProxyName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupResourceGuardProxyName'", id.BackupResourceGuardProxyName, "backupResourceGuardProxyName") + } +} + +func TestFormatBackupResourceGuardProxyID(t *testing.T) { + actual := NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupResourceGuardProxyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupResourceGuardProxies/backupResourceGuardProxyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupResourceGuardProxyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupResourceGuardProxyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupResourceGuardProxies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupResourceGuardProxies/backupResourceGuardProxyName", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupResourceGuardProxyName: "backupResourceGuardProxyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupResourceGuardProxies/backupResourceGuardProxyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupResourceGuardProxyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupResourceGuardProxyName != v.Expected.BackupResourceGuardProxyName { + t.Fatalf("Expected %q but got %q for BackupResourceGuardProxyName", v.Expected.BackupResourceGuardProxyName, actual.BackupResourceGuardProxyName) + } + + } +} + +func TestParseBackupResourceGuardProxyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupResourceGuardProxyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupResourceGuardProxies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPrEsOuRcEgUaRdPrOxIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupResourceGuardProxies/backupResourceGuardProxyName", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupResourceGuardProxyName: "backupResourceGuardProxyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupResourceGuardProxies/backupResourceGuardProxyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPrEsOuRcEgUaRdPrOxIeS/bAcKuPrEsOuRcEgUaRdPrOxYnAmE", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupResourceGuardProxyName: "bAcKuPrEsOuRcEgUaRdPrOxYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPrEsOuRcEgUaRdPrOxIeS/bAcKuPrEsOuRcEgUaRdPrOxYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupResourceGuardProxyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupResourceGuardProxyName != v.Expected.BackupResourceGuardProxyName { + t.Fatalf("Expected %q but got %q for BackupResourceGuardProxyName", v.Expected.BackupResourceGuardProxyName, actual.BackupResourceGuardProxyName) + } + + } +} + +func TestSegmentsForBackupResourceGuardProxyId(t *testing.T) { + segments := BackupResourceGuardProxyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupResourceGuardProxyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_delete_autorest.go new file mode 100644 index 00000000000..5bc566a1459 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_delete_autorest.go @@ -0,0 +1,66 @@ +package resourceguardproxy + +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 ResourceGuardProxyClient) Delete(ctx context.Context, id BackupResourceGuardProxyId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c ResourceGuardProxyClient) preparerForDelete(ctx context.Context, id BackupResourceGuardProxyId) (*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 ResourceGuardProxyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_get_autorest.go new file mode 100644 index 00000000000..34cbc308b05 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_get_autorest.go @@ -0,0 +1,68 @@ +package resourceguardproxy + +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 *ResourceGuardProxyBaseResource +} + +// Get ... +func (c ResourceGuardProxyClient) Get(ctx context.Context, id BackupResourceGuardProxyId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ResourceGuardProxyClient) preparerForGet(ctx context.Context, id BackupResourceGuardProxyId) (*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 ResourceGuardProxyClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_put_autorest.go new file mode 100644 index 00000000000..251f699920c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_put_autorest.go @@ -0,0 +1,69 @@ +package resourceguardproxy + +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 PutOperationResponse struct { + HttpResponse *http.Response + Model *ResourceGuardProxyBaseResource +} + +// Put ... +func (c ResourceGuardProxyClient) Put(ctx context.Context, id BackupResourceGuardProxyId, input ResourceGuardProxyBaseResource) (result PutOperationResponse, err error) { + req, err := c.preparerForPut(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPut(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForPut prepares the Put request. +func (c ResourceGuardProxyClient) preparerForPut(ctx context.Context, id BackupResourceGuardProxyId, input ResourceGuardProxyBaseResource) (*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)) +} + +// responderForPut handles the response to the Put request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_unlockdelete_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_unlockdelete_autorest.go new file mode 100644 index 00000000000..4ddf4864869 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/method_unlockdelete_autorest.go @@ -0,0 +1,70 @@ +package resourceguardproxy + +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 UnlockDeleteOperationResponse struct { + HttpResponse *http.Response + Model *UnlockDeleteResponse +} + +// UnlockDelete ... +func (c ResourceGuardProxyClient) UnlockDelete(ctx context.Context, id BackupResourceGuardProxyId, input UnlockDeleteRequest) (result UnlockDeleteOperationResponse, err error) { + req, err := c.preparerForUnlockDelete(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUnlockDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUnlockDelete prepares the UnlockDelete request. +func (c ResourceGuardProxyClient) preparerForUnlockDelete(ctx context.Context, id BackupResourceGuardProxyId, input UnlockDeleteRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/unlockDelete", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUnlockDelete handles the response to the UnlockDelete request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForUnlockDelete(resp *http.Response) (result UnlockDeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardoperationdetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardoperationdetail.go new file mode 100644 index 00000000000..a211e1f34bb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardoperationdetail.go @@ -0,0 +1,9 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardOperationDetail struct { + DefaultResourceRequest *string `json:"defaultResourceRequest,omitempty"` + VaultCriticalOperation *string `json:"vaultCriticalOperation,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardproxybase.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardproxybase.go new file mode 100644 index 00000000000..9e601e04d32 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardproxybase.go @@ -0,0 +1,11 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBase struct { + Description *string `json:"description,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + ResourceGuardOperationDetails *[]ResourceGuardOperationDetail `json:"resourceGuardOperationDetails,omitempty"` + ResourceGuardResourceId string `json:"resourceGuardResourceId"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardproxybaseresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardproxybaseresource.go new file mode 100644 index 00000000000..f68fdd803b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_resourceguardproxybaseresource.go @@ -0,0 +1,14 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceGuardProxyBase `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_unlockdeleterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_unlockdeleterequest.go new file mode 100644 index 00000000000..5ed0ee6ebfe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_unlockdeleterequest.go @@ -0,0 +1,9 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteRequest struct { + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + ResourceToBeDeleted *string `json:"resourceToBeDeleted,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_unlockdeleteresponse.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_unlockdeleteresponse.go new file mode 100644 index 00000000000..6304a0fa5e6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/model_unlockdeleteresponse.go @@ -0,0 +1,8 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteResponse struct { + UnlockDeleteExpiryTime *string `json:"unlockDeleteExpiryTime,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/version.go new file mode 100644 index 00000000000..b1d674e4017 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/resourceguardproxy/version.go @@ -0,0 +1,10 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resourceguardproxy/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/restores/README.md new file mode 100644 index 00000000000..2bd4a660e51 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/restores` Documentation + +The `restores` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/restores" +``` + + +### Client Initialization + +```go +client := restores.NewRestoresClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RestoresClient.Trigger` + +```go +ctx := context.TODO() +id := restores.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + +payload := restores.RestoreRequestResource{ + // ... +} + + +if err := client.TriggerThenPoll(ctx, id, payload, restores.DefaultTriggerOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/client.go new file mode 100644 index 00000000000..3263d991a1e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/client.go @@ -0,0 +1,18 @@ +package restores + +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 RestoresClient struct { + Client autorest.Client + baseUri string +} + +func NewRestoresClientWithBaseURI(endpoint string) RestoresClient { + return RestoresClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/constants.go new file mode 100644 index 00000000000..57a0db7b579 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/constants.go @@ -0,0 +1,274 @@ +package restores + +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 CopyOptions string + +const ( + CopyOptionsCreateCopy CopyOptions = "CreateCopy" + CopyOptionsFailOnConflict CopyOptions = "FailOnConflict" + CopyOptionsInvalid CopyOptions = "Invalid" + CopyOptionsOverwrite CopyOptions = "Overwrite" + CopyOptionsSkip CopyOptions = "Skip" +) + +func PossibleValuesForCopyOptions() []string { + return []string{ + string(CopyOptionsCreateCopy), + string(CopyOptionsFailOnConflict), + string(CopyOptionsInvalid), + string(CopyOptionsOverwrite), + string(CopyOptionsSkip), + } +} + +func parseCopyOptions(input string) (*CopyOptions, error) { + vals := map[string]CopyOptions{ + "createcopy": CopyOptionsCreateCopy, + "failonconflict": CopyOptionsFailOnConflict, + "invalid": CopyOptionsInvalid, + "overwrite": CopyOptionsOverwrite, + "skip": CopyOptionsSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CopyOptions(input) + return &out, nil +} + +type OverwriteOptions string + +const ( + OverwriteOptionsFailOnConflict OverwriteOptions = "FailOnConflict" + OverwriteOptionsInvalid OverwriteOptions = "Invalid" + OverwriteOptionsOverwrite OverwriteOptions = "Overwrite" +) + +func PossibleValuesForOverwriteOptions() []string { + return []string{ + string(OverwriteOptionsFailOnConflict), + string(OverwriteOptionsInvalid), + string(OverwriteOptionsOverwrite), + } +} + +func parseOverwriteOptions(input string) (*OverwriteOptions, error) { + vals := map[string]OverwriteOptions{ + "failonconflict": OverwriteOptionsFailOnConflict, + "invalid": OverwriteOptionsInvalid, + "overwrite": OverwriteOptionsOverwrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverwriteOptions(input) + return &out, nil +} + +type RecoveryMode string + +const ( + RecoveryModeFileRecovery RecoveryMode = "FileRecovery" + RecoveryModeInvalid RecoveryMode = "Invalid" + RecoveryModeRecoveryUsingSnapshot RecoveryMode = "RecoveryUsingSnapshot" + RecoveryModeSnapshotAttach RecoveryMode = "SnapshotAttach" + RecoveryModeSnapshotAttachAndRecover RecoveryMode = "SnapshotAttachAndRecover" + RecoveryModeWorkloadRecovery RecoveryMode = "WorkloadRecovery" +) + +func PossibleValuesForRecoveryMode() []string { + return []string{ + string(RecoveryModeFileRecovery), + string(RecoveryModeInvalid), + string(RecoveryModeRecoveryUsingSnapshot), + string(RecoveryModeSnapshotAttach), + string(RecoveryModeSnapshotAttachAndRecover), + string(RecoveryModeWorkloadRecovery), + } +} + +func parseRecoveryMode(input string) (*RecoveryMode, error) { + vals := map[string]RecoveryMode{ + "filerecovery": RecoveryModeFileRecovery, + "invalid": RecoveryModeInvalid, + "recoveryusingsnapshot": RecoveryModeRecoveryUsingSnapshot, + "snapshotattach": RecoveryModeSnapshotAttach, + "snapshotattachandrecover": RecoveryModeSnapshotAttachAndRecover, + "workloadrecovery": RecoveryModeWorkloadRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryMode(input) + return &out, nil +} + +type RecoveryType string + +const ( + RecoveryTypeAlternateLocation RecoveryType = "AlternateLocation" + RecoveryTypeInvalid RecoveryType = "Invalid" + RecoveryTypeOffline RecoveryType = "Offline" + RecoveryTypeOriginalLocation RecoveryType = "OriginalLocation" + RecoveryTypeRestoreDisks RecoveryType = "RestoreDisks" +) + +func PossibleValuesForRecoveryType() []string { + return []string{ + string(RecoveryTypeAlternateLocation), + string(RecoveryTypeInvalid), + string(RecoveryTypeOffline), + string(RecoveryTypeOriginalLocation), + string(RecoveryTypeRestoreDisks), + } +} + +func parseRecoveryType(input string) (*RecoveryType, error) { + vals := map[string]RecoveryType{ + "alternatelocation": RecoveryTypeAlternateLocation, + "invalid": RecoveryTypeInvalid, + "offline": RecoveryTypeOffline, + "originallocation": RecoveryTypeOriginalLocation, + "restoredisks": RecoveryTypeRestoreDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryType(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityStandard), + } +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} + +type RestoreRequestType string + +const ( + RestoreRequestTypeFullShareRestore RestoreRequestType = "FullShareRestore" + RestoreRequestTypeInvalid RestoreRequestType = "Invalid" + RestoreRequestTypeItemLevelRestore RestoreRequestType = "ItemLevelRestore" +) + +func PossibleValuesForRestoreRequestType() []string { + return []string{ + string(RestoreRequestTypeFullShareRestore), + string(RestoreRequestTypeInvalid), + string(RestoreRequestTypeItemLevelRestore), + } +} + +func parseRestoreRequestType(input string) (*RestoreRequestType, error) { + vals := map[string]RestoreRequestType{ + "fullsharerestore": RestoreRequestTypeFullShareRestore, + "invalid": RestoreRequestTypeInvalid, + "itemlevelrestore": RestoreRequestTypeItemLevelRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreRequestType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} + +type TargetDiskNetworkAccessOption string + +const ( + TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePrivateAccessForAllDisks" + TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePublicAccessForAllDisks" + TargetDiskNetworkAccessOptionSameAsOnSourceDisks TargetDiskNetworkAccessOption = "SameAsOnSourceDisks" +) + +func PossibleValuesForTargetDiskNetworkAccessOption() []string { + return []string{ + string(TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks), + string(TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks), + string(TargetDiskNetworkAccessOptionSameAsOnSourceDisks), + } +} + +func parseTargetDiskNetworkAccessOption(input string) (*TargetDiskNetworkAccessOption, error) { + vals := map[string]TargetDiskNetworkAccessOption{ + "enableprivateaccessforalldisks": TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks, + "enablepublicaccessforalldisks": TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks, + "sameasonsourcedisks": TargetDiskNetworkAccessOptionSameAsOnSourceDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetDiskNetworkAccessOption(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/id_recoverypoint.go new file mode 100644 index 00000000000..863cfe24ce1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/id_recoverypoint.go @@ -0,0 +1,166 @@ +package restores + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(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 := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) 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", "vaultName"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricName"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerName"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemName"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointId"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) 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), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/id_recoverypoint_test.go new file mode 100644 index 00000000000..ff387277ecc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package restores + +import ( + "testing" + + "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 = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.BackupFabricName != "backupFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricName") + } + + if id.ProtectionContainerName != "protectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerName") + } + + if id.ProtectedItemName != "protectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemName") + } + + if id.RecoveryPointId != "recoveryPointId" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointId") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName", "recoveryPointId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + RecoveryPointId: "recoveryPointId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + BackupFabricName: "backupFabricName", + ProtectionContainerName: "protectionContainerName", + ProtectedItemName: "protectedItemName", + RecoveryPointId: "recoveryPointId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/backupFabrics/backupFabricName/protectionContainers/protectionContainerName/protectedItems/protectedItemName/recoveryPoints/recoveryPointId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS/rEcOvErYpOiNtId", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + BackupFabricName: "bAcKuPfAbRiCnAmE", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErNaMe", + ProtectedItemName: "pRoTeCtEdItEmNaMe", + RecoveryPointId: "rEcOvErYpOiNtId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/bAcKuPfAbRiCs/bAcKuPfAbRiCnAmE/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErNaMe/pRoTeCtEdItEmS/pRoTeCtEdItEmNaMe/rEcOvErYpOiNtS/rEcOvErYpOiNtId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/method_trigger_autorest.go new file mode 100644 index 00000000000..a5e6e3ece2a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/method_trigger_autorest.go @@ -0,0 +1,108 @@ +package restores + +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 TriggerOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +type TriggerOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultTriggerOperationOptions() TriggerOperationOptions { + return TriggerOperationOptions{} +} + +func (o TriggerOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o TriggerOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Trigger ... +func (c RestoresClient) Trigger(ctx context.Context, id RecoveryPointId, input RestoreRequestResource, options TriggerOperationOptions) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "restores.RestoresClient", "Trigger", nil, "Failure preparing request") + return + } + + result, err = c.senderForTrigger(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "restores.RestoresClient", "Trigger", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// TriggerThenPoll performs Trigger then polls until it's completed +func (c RestoresClient) TriggerThenPoll(ctx context.Context, id RecoveryPointId, input RestoreRequestResource, options TriggerOperationOptions) error { + result, err := c.Trigger(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Trigger: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Trigger: %+v", err) + } + + return nil +} + +// preparerForTrigger prepares the Trigger request. +func (c RestoresClient) preparerForTrigger(ctx context.Context, id RecoveryPointId, input RestoreRequestResource, options TriggerOperationOptions) (*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/restore", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForTrigger sends the Trigger request. The method will close the +// http.Response Body if it receives an error. +func (c RestoresClient) senderForTrigger(ctx context.Context, req *http.Request) (future TriggerOperationResponse, 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/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..26331ae6957 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azurefilesharerestorerequest.go @@ -0,0 +1,57 @@ +package restores + +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 _ RestoreRequest = AzureFileShareRestoreRequest{} + +type AzureFileShareRestoreRequest struct { + CopyOptions *CopyOptions `json:"copyOptions,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + RestoreFileSpecs *[]RestoreFileSpecs `json:"restoreFileSpecs,omitempty"` + RestoreRequestType *RestoreRequestType `json:"restoreRequestType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetDetails *TargetAFSRestoreInfo `json:"targetDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureFileShareRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureFileShareRestoreRequest{} + +func (s AzureFileShareRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureFileShareRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..6634b8fe275 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,61 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadPointInTimeRestoreRequest{} + +type AzureWorkloadPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRestoreRequest{} + +func (s AzureWorkloadPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..cda3c7d97fb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadrestorerequest.go @@ -0,0 +1,60 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadRestoreRequest{} + +type AzureWorkloadRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadRestoreRequest{} + +func (s AzureWorkloadRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..a927f196d4f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,61 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..ffe2aca7c57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,62 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..52a8f3e28f4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,60 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadSAPHanaRestoreRequest{} + +type AzureWorkloadSAPHanaRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreRequest{} + +func (s AzureWorkloadSAPHanaRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..1eef91bb385 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,61 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaRestoreWithRehydrateRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..aa7e8105e95 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,64 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreRequest{} + +type AzureWorkloadSQLPointInTimeRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..ee708d99b3b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,65 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..48575eca7e9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,63 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadSQLRestoreRequest{} + +type AzureWorkloadSQLRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreRequest{} + +func (s AzureWorkloadSQLRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..209f41614eb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,64 @@ +package restores + +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 _ RestoreRequest = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_encryptiondetails.go new file mode 100644 index 00000000000..9351ce35d30 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_encryptiondetails.go @@ -0,0 +1,12 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionDetails struct { + EncryptionEnabled *bool `json:"encryptionEnabled,omitempty"` + KekURL *string `json:"kekUrl,omitempty"` + KekVaultId *string `json:"kekVaultId,omitempty"` + SecretKeyURL *string `json:"secretKeyUrl,omitempty"` + SecretKeyVaultId *string `json:"secretKeyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_extendedlocation.go new file mode 100644 index 00000000000..379c8d626ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_extendedlocation.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..40102c3cab9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_iaasvmrestorerequest.go @@ -0,0 +1,76 @@ +package restores + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreRequest{} + +type IaasVMRestoreRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s IaasVMRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = IaasVMRestoreRequest{} + +func (s IaasVMRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreRequest: %+v", err) + } + + decoded["objectType"] = "IaasVMRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..dd6cb2158e9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,77 @@ +package restores + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreWithRehydrationRequest{} + +type IaasVMRestoreWithRehydrationRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s IaasVMRestoreWithRehydrationRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = IaasVMRestoreWithRehydrationRequest{} + +func (s IaasVMRestoreWithRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreWithRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + decoded["objectType"] = "IaasVMRestoreWithRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..a9c51c27edc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_identitybasedrestoredetails.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityBasedRestoreDetails struct { + ObjectType *string `json:"objectType,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_identityinfo.go new file mode 100644 index 00000000000..54e5f53f23c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_identityinfo.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityInfo struct { + IsSystemAssignedIdentity *bool `json:"isSystemAssignedIdentity,omitempty"` + ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..73a3eba8ff1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_recoverypointrehydrationinfo.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointRehydrationInfo struct { + RehydrationPriority *RehydrationPriority `json:"rehydrationPriority,omitempty"` + RehydrationRetentionDuration *string `json:"rehydrationRetentionDuration,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorefilespecs.go new file mode 100644 index 00000000000..717dcbaffd2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorefilespecs.go @@ -0,0 +1,10 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFileSpecs struct { + FileSpecType *string `json:"fileSpecType,omitempty"` + Path *string `json:"path,omitempty"` + TargetFolderPath *string `json:"targetFolderPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorerequest.go new file mode 100644 index 00000000000..a2903f268de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorerequest.go @@ -0,0 +1,172 @@ +package restores + +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 RestoreRequest interface { + RestoreRequest() BaseRestoreRequestImpl +} + +var _ RestoreRequest = BaseRestoreRequestImpl{} + +type BaseRestoreRequestImpl struct { + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s BaseRestoreRequestImpl) RestoreRequest() BaseRestoreRequestImpl { + return s +} + +var _ RestoreRequest = RawRestoreRequestImpl{} + +// RawRestoreRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRestoreRequestImpl struct { + restoreRequest BaseRestoreRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawRestoreRequestImpl) RestoreRequest() BaseRestoreRequestImpl { + return s.restoreRequest +} + +func UnmarshalRestoreRequestImplementation(input []byte) (RestoreRequest, 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 RestoreRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureFileShareRestoreRequest") { + var out AzureFileShareRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRestoreRequest") { + var out AzureWorkloadPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRestoreRequest") { + var out AzureWorkloadRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreRequest") { + var out AzureWorkloadSAPHanaRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreRequest") { + var out AzureWorkloadSQLPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreRequest") { + var out AzureWorkloadSQLRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreRequest") { + var out IaasVMRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreWithRehydrationRequest") { + var out IaasVMRestoreWithRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreWithRehydrationRequest: %+v", err) + } + return out, nil + } + + var parent BaseRestoreRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRestoreRequestImpl: %+v", err) + } + + return RawRestoreRequestImpl{ + restoreRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorerequestresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorerequestresource.go new file mode 100644 index 00000000000..2b5b7e15157 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_restorerequestresource.go @@ -0,0 +1,57 @@ +package restores + +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 RestoreRequestResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties RestoreRequest `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &RestoreRequestResource{} + +func (s *RestoreRequestResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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 RestoreRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'RestoreRequestResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_securedvmdetails.go new file mode 100644 index 00000000000..f83115fc592 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_securedvmdetails.go @@ -0,0 +1,8 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuredVMDetails struct { + SecuredVMOsDiskEncryptionSetId *string `json:"securedVMOsDiskEncryptionSetId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..dcd5798e292 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_snapshotrestoreparameters.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreParameters struct { + LogPointInTimeForDBRecovery *string `json:"logPointInTimeForDBRecovery,omitempty"` + SkipAttachAndMount *bool `json:"skipAttachAndMount,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..6a51b7654a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_sqldatadirectorymapping.go @@ -0,0 +1,11 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectoryMapping struct { + MappingType *SQLDataDirectoryType `json:"mappingType,omitempty"` + SourceLogicalName *string `json:"sourceLogicalName,omitempty"` + SourcePath *string `json:"sourcePath,omitempty"` + TargetPath *string `json:"targetPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..c87d917d3d7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetafsrestoreinfo.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetAFSRestoreInfo struct { + Name *string `json:"name,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..a4aef071ffb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetdisknetworkaccesssettings.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetDiskNetworkAccessSettings struct { + TargetDiskAccessId *string `json:"targetDiskAccessId,omitempty"` + TargetDiskNetworkAccessOption *TargetDiskNetworkAccessOption `json:"targetDiskNetworkAccessOption,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetrestoreinfo.go new file mode 100644 index 00000000000..84b61c24b37 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_targetrestoreinfo.go @@ -0,0 +1,11 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetRestoreInfo struct { + ContainerId *string `json:"containerId,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + OverwriteOption *OverwriteOptions `json:"overwriteOption,omitempty"` + TargetDirectoryForFileRestore *string `json:"targetDirectoryForFileRestore,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..af278e430c4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..0544cfe81fe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/restores/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/restores/version.go new file mode 100644 index 00000000000..f50c4649497 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/restores/version.go @@ -0,0 +1,10 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/restores/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/README.md new file mode 100644 index 00000000000..143153f0fe6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/securitypins` Documentation + +The `securitypins` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/securitypins" +``` + + +### Client Initialization + +```go +client := securitypins.NewSecurityPINsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityPINsClient.Get` + +```go +ctx := context.TODO() +id := securitypins.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := securitypins.SecurityPinBase{ + // ... +} + + +read, err := client.Get(ctx, id, payload, securitypins.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/client.go new file mode 100644 index 00000000000..117208a5554 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/client.go @@ -0,0 +1,18 @@ +package securitypins + +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 SecurityPINsClient struct { + Client autorest.Client + baseUri string +} + +func NewSecurityPINsClientWithBaseURI(endpoint string) SecurityPINsClient { + return SecurityPINsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/id_vault.go new file mode 100644 index 00000000000..1c836e9efd5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/id_vault.go @@ -0,0 +1,130 @@ +package securitypins + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/id_vault_test.go new file mode 100644 index 00000000000..823ad306d4b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/id_vault_test.go @@ -0,0 +1,282 @@ +package securitypins + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/method_get_autorest.go new file mode 100644 index 00000000000..7680900edb8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/method_get_autorest.go @@ -0,0 +1,99 @@ +package securitypins + +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 GetOperationResponse struct { + HttpResponse *http.Response + Model *TokenInformation +} + +type GetOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o GetOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Get ... +func (c SecurityPINsClient) Get(ctx context.Context, id VaultId, input SecurityPinBase, options GetOperationOptions) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "securitypins.SecurityPINsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "securitypins.SecurityPINsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "securitypins.SecurityPINsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c SecurityPINsClient) preparerForGet(ctx context.Context, id VaultId, input SecurityPinBase, 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.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupSecurityPIN", id.ID())), + autorest.WithJSON(input), + 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 SecurityPINsClient) 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/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/model_securitypinbase.go b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/model_securitypinbase.go new file mode 100644 index 00000000000..acc76db8d99 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/model_securitypinbase.go @@ -0,0 +1,8 @@ +package securitypins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPinBase struct { + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/model_tokeninformation.go b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/model_tokeninformation.go new file mode 100644 index 00000000000..cfebb48a56d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/model_tokeninformation.go @@ -0,0 +1,10 @@ +package securitypins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TokenInformation struct { + ExpiryTimeInUtcTicks *int64 `json:"expiryTimeInUtcTicks,omitempty"` + SecurityPIN *string `json:"securityPIN,omitempty"` + Token *string `json:"token,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/version.go new file mode 100644 index 00000000000..409bd890062 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/securitypins/version.go @@ -0,0 +1,10 @@ +package securitypins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/securitypins/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/README.md new file mode 100644 index 00000000000..333ae83bccf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers` Documentation + +The `softdeletedcontainers` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/softdeletedcontainers" +``` + + +### Client Initialization + +```go +client := softdeletedcontainers.NewSoftDeletedContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SoftDeletedContainersClient.DeletedProtectionContainersList` + +```go +ctx := context.TODO() +id := softdeletedcontainers.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.DeletedProtectionContainersList(ctx, id, softdeletedcontainers.DefaultDeletedProtectionContainersListOperationOptions())` can be used to do batched pagination +items, err := client.DeletedProtectionContainersListComplete(ctx, id, softdeletedcontainers.DefaultDeletedProtectionContainersListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/client.go new file mode 100644 index 00000000000..a671a0559b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/client.go @@ -0,0 +1,18 @@ +package softdeletedcontainers + +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 SoftDeletedContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewSoftDeletedContainersClientWithBaseURI(endpoint string) SoftDeletedContainersClient { + return SoftDeletedContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/constants.go new file mode 100644 index 00000000000..b5d5b80be6e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/constants.go @@ -0,0 +1,332 @@ +package softdeletedcontainers + +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" + BackupItemTypeSAPHanaDBInstance BackupItemType = "SAPHanaDBInstance" + 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(BackupItemTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": BackupItemTypeSAPHanaDBInstance, + "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 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 ProtectableContainerType string + +const ( + ProtectableContainerTypeAzureBackupServerContainer ProtectableContainerType = "AzureBackupServerContainer" + ProtectableContainerTypeAzureSqlContainer ProtectableContainerType = "AzureSqlContainer" + ProtectableContainerTypeAzureWorkloadContainer ProtectableContainerType = "AzureWorkloadContainer" + ProtectableContainerTypeCluster ProtectableContainerType = "Cluster" + ProtectableContainerTypeDPMContainer ProtectableContainerType = "DPMContainer" + ProtectableContainerTypeGenericContainer ProtectableContainerType = "GenericContainer" + ProtectableContainerTypeIaasVMContainer ProtectableContainerType = "IaasVMContainer" + ProtectableContainerTypeIaasVMServiceContainer ProtectableContainerType = "IaasVMServiceContainer" + ProtectableContainerTypeInvalid ProtectableContainerType = "Invalid" + ProtectableContainerTypeMABContainer ProtectableContainerType = "MABContainer" + ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines ProtectableContainerType = "Microsoft.ClassicCompute/virtualMachines" + ProtectableContainerTypeMicrosoftPointComputeVirtualMachines ProtectableContainerType = "Microsoft.Compute/virtualMachines" + ProtectableContainerTypeSQLAGWorkLoadContainer ProtectableContainerType = "SQLAGWorkLoadContainer" + ProtectableContainerTypeStorageContainer ProtectableContainerType = "StorageContainer" + ProtectableContainerTypeUnknown ProtectableContainerType = "Unknown" + ProtectableContainerTypeVCenter ProtectableContainerType = "VCenter" + ProtectableContainerTypeVMAppContainer ProtectableContainerType = "VMAppContainer" + ProtectableContainerTypeWindows ProtectableContainerType = "Windows" +) + +func PossibleValuesForProtectableContainerType() []string { + return []string{ + string(ProtectableContainerTypeAzureBackupServerContainer), + string(ProtectableContainerTypeAzureSqlContainer), + string(ProtectableContainerTypeAzureWorkloadContainer), + string(ProtectableContainerTypeCluster), + string(ProtectableContainerTypeDPMContainer), + string(ProtectableContainerTypeGenericContainer), + string(ProtectableContainerTypeIaasVMContainer), + string(ProtectableContainerTypeIaasVMServiceContainer), + string(ProtectableContainerTypeInvalid), + string(ProtectableContainerTypeMABContainer), + string(ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ProtectableContainerTypeMicrosoftPointComputeVirtualMachines), + string(ProtectableContainerTypeSQLAGWorkLoadContainer), + string(ProtectableContainerTypeStorageContainer), + string(ProtectableContainerTypeUnknown), + string(ProtectableContainerTypeVCenter), + string(ProtectableContainerTypeVMAppContainer), + string(ProtectableContainerTypeWindows), + } +} + +func parseProtectableContainerType(input string) (*ProtectableContainerType, error) { + vals := map[string]ProtectableContainerType{ + "azurebackupservercontainer": ProtectableContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ProtectableContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ProtectableContainerTypeAzureWorkloadContainer, + "cluster": ProtectableContainerTypeCluster, + "dpmcontainer": ProtectableContainerTypeDPMContainer, + "genericcontainer": ProtectableContainerTypeGenericContainer, + "iaasvmcontainer": ProtectableContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ProtectableContainerTypeIaasVMServiceContainer, + "invalid": ProtectableContainerTypeInvalid, + "mabcontainer": ProtectableContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ProtectableContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ProtectableContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ProtectableContainerTypeStorageContainer, + "unknown": ProtectableContainerTypeUnknown, + "vcenter": ProtectableContainerTypeVCenter, + "vmappcontainer": ProtectableContainerTypeVMAppContainer, + "windows": ProtectableContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectableContainerType(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" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + 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(WorkloadTypeSAPHanaDBInstance), + 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, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/id_vault.go new file mode 100644 index 00000000000..d4caae9a90c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/id_vault.go @@ -0,0 +1,130 @@ +package softdeletedcontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/id_vault_test.go new file mode 100644 index 00000000000..c1ea724ab7c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/id_vault_test.go @@ -0,0 +1,282 @@ +package softdeletedcontainers + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go new file mode 100644 index 00000000000..412ffcc44a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go @@ -0,0 +1,215 @@ +package softdeletedcontainers + +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 DeletedProtectionContainersListOperationResponse struct { + HttpResponse *http.Response + Model *[]ProtectionContainerResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (DeletedProtectionContainersListOperationResponse, error) +} + +type DeletedProtectionContainersListCompleteResult struct { + Items []ProtectionContainerResource +} + +func (r DeletedProtectionContainersListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r DeletedProtectionContainersListOperationResponse) LoadMore(ctx context.Context) (resp DeletedProtectionContainersListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type DeletedProtectionContainersListOperationOptions struct { + Filter *string +} + +func DefaultDeletedProtectionContainersListOperationOptions() DeletedProtectionContainersListOperationOptions { + return DeletedProtectionContainersListOperationOptions{} +} + +func (o DeletedProtectionContainersListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o DeletedProtectionContainersListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// DeletedProtectionContainersList ... +func (c SoftDeletedContainersClient) DeletedProtectionContainersList(ctx context.Context, id VaultId, options DeletedProtectionContainersListOperationOptions) (resp DeletedProtectionContainersListOperationResponse, err error) { + req, err := c.preparerForDeletedProtectionContainersList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForDeletedProtectionContainersList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForDeletedProtectionContainersList prepares the DeletedProtectionContainersList request. +func (c SoftDeletedContainersClient) preparerForDeletedProtectionContainersList(ctx context.Context, id VaultId, options DeletedProtectionContainersListOperationOptions) (*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/backupDeletedProtectionContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForDeletedProtectionContainersListWithNextLink prepares the DeletedProtectionContainersList request with the given nextLink token. +func (c SoftDeletedContainersClient) preparerForDeletedProtectionContainersListWithNextLink(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)) +} + +// responderForDeletedProtectionContainersList handles the response to the DeletedProtectionContainersList request. The method always +// closes the http.Response Body. +func (c SoftDeletedContainersClient) responderForDeletedProtectionContainersList(resp *http.Response) (result DeletedProtectionContainersListOperationResponse, err error) { + type page struct { + Values []ProtectionContainerResource `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 DeletedProtectionContainersListOperationResponse, err error) { + req, err := c.preparerForDeletedProtectionContainersListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDeletedProtectionContainersList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// DeletedProtectionContainersListComplete retrieves all of the results into a single object +func (c SoftDeletedContainersClient) DeletedProtectionContainersListComplete(ctx context.Context, id VaultId, options DeletedProtectionContainersListOperationOptions) (DeletedProtectionContainersListCompleteResult, error) { + return c.DeletedProtectionContainersListCompleteMatchingPredicate(ctx, id, options, ProtectionContainerResourceOperationPredicate{}) +} + +// DeletedProtectionContainersListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c SoftDeletedContainersClient) DeletedProtectionContainersListCompleteMatchingPredicate(ctx context.Context, id VaultId, options DeletedProtectionContainersListOperationOptions, predicate ProtectionContainerResourceOperationPredicate) (resp DeletedProtectionContainersListCompleteResult, err error) { + items := make([]ProtectionContainerResource, 0) + + page, err := c.DeletedProtectionContainersList(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 := DeletedProtectionContainersListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..a69df42e95d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurebackupservercontainer.go @@ -0,0 +1,67 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureBackupServerContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..f71ebe1ecbc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,62 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureIaaSClassicComputeVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..b44b93046f3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,62 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureIaaSComputeVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..aab5648fb34 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,64 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..62794d1b909 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azuresqlcontainer.go @@ -0,0 +1,59 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureSqlContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..db8491278c3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurestoragecontainer.go @@ -0,0 +1,64 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureStorageContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..8dad4ff2e28 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,64 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureVMAppContainerProtectionContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..9004ee18921 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureworkloadcontainer.go @@ -0,0 +1,64 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s AzureWorkloadContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..141007ebdda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..367cba6804a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_containeridentityinfo.go @@ -0,0 +1,11 @@ +package softdeletedcontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..3e35634654c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +package softdeletedcontainers + +// 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"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..d0c9d4884ea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_dpmcontainer.go @@ -0,0 +1,67 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s DpmContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..c0f911a34b6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go @@ -0,0 +1,26 @@ +package softdeletedcontainers + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_errordetail.go new file mode 100644 index 00000000000..b76617c0e57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_errordetail.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_genericcontainer.go new file mode 100644 index 00000000000..9c4a0613590 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_genericcontainer.go @@ -0,0 +1,61 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s GenericContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..79e66b1ffda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_genericcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..1688f64cf3f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_iaasvmcontainer.go @@ -0,0 +1,62 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s IaaSVMContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..c4d9f8360b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_inquiryinfo.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..5d9553ccad7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_inquiryvalidation.go @@ -0,0 +1,11 @@ +package softdeletedcontainers + +// 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"` + ProtectableItemCount *interface{} `json:"protectableItemCount,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainer.go new file mode 100644 index 00000000000..df406541f1b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainer.go @@ -0,0 +1,66 @@ +package softdeletedcontainers + +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"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s MabContainer) ProtectionContainer() BaseProtectionContainerImpl { + return BaseProtectionContainerImpl{ + BackupManagementType: s.BackupManagementType, + ContainerType: s.ContainerType, + FriendlyName: s.FriendlyName, + HealthStatus: s.HealthStatus, + ProtectableObjectType: s.ProtectableObjectType, + RegistrationStatus: s.RegistrationStatus, + } +} + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..a5bc672fcf2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainerextendedinfo.go @@ -0,0 +1,30 @@ +package softdeletedcontainers + +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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..8e91b126cc6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_mabcontainerhealthdetails.go @@ -0,0 +1,11 @@ +package softdeletedcontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..d8facb14a2f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_protectioncontainer.go @@ -0,0 +1,168 @@ +package softdeletedcontainers + +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 { + ProtectionContainer() BaseProtectionContainerImpl +} + +var _ ProtectionContainer = BaseProtectionContainerImpl{} + +type BaseProtectionContainerImpl struct { + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ContainerType ProtectableContainerType `json:"containerType"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +func (s BaseProtectionContainerImpl) ProtectionContainer() BaseProtectionContainerImpl { + return s +} + +var _ ProtectionContainer = RawProtectionContainerImpl{} + +// RawProtectionContainerImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionContainerImpl struct { + protectionContainer BaseProtectionContainerImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionContainerImpl) ProtectionContainer() BaseProtectionContainerImpl { + return s.protectionContainer +} + +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) + } + + var value string + if v, ok := temp["containerType"]; ok { + value = fmt.Sprintf("%v", v) + } + + 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 + } + + var parent BaseProtectionContainerImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionContainerImpl: %+v", err) + } + + return RawProtectionContainerImpl{ + protectionContainer: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..c3d8898f9df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_protectioncontainerresource.go @@ -0,0 +1,57 @@ +package softdeletedcontainers + +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 { + var decoded struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..ca519886a94 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/model_workloadinquirydetails.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/predicates.go new file mode 100644 index 00000000000..65cbf0427e6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/predicates.go @@ -0,0 +1,37 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerResourceOperationPredicate) Matches(input ProtectionContainerResource) 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/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/version.go new file mode 100644 index 00000000000..cc0f897ba2d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/softdeletedcontainers/version.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/softdeletedcontainers/2024-10-01" +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/README.md b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/README.md new file mode 100644 index 00000000000..1cdfccc5f7b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation` Documentation + +The `validateoperation` SDK allows for interaction with Azure Resource Manager `recoveryservicesbackup` (API Version `2024-10-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/2024-10-01/validateoperation" +``` + + +### Client Initialization + +```go +client := validateoperation.NewValidateOperationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ValidateOperationClient.Trigger` + +```go +ctx := context.TODO() +id := validateoperation.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := validateoperation.ValidateOperationRequestResource{ + // ... +} + + +if err := client.TriggerThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/client.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/client.go new file mode 100644 index 00000000000..e729f452d88 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/client.go @@ -0,0 +1,18 @@ +package validateoperation + +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 ValidateOperationClient struct { + Client autorest.Client + baseUri string +} + +func NewValidateOperationClientWithBaseURI(endpoint string) ValidateOperationClient { + return ValidateOperationClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/constants.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/constants.go new file mode 100644 index 00000000000..cbbc4e1670c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/constants.go @@ -0,0 +1,274 @@ +package validateoperation + +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 CopyOptions string + +const ( + CopyOptionsCreateCopy CopyOptions = "CreateCopy" + CopyOptionsFailOnConflict CopyOptions = "FailOnConflict" + CopyOptionsInvalid CopyOptions = "Invalid" + CopyOptionsOverwrite CopyOptions = "Overwrite" + CopyOptionsSkip CopyOptions = "Skip" +) + +func PossibleValuesForCopyOptions() []string { + return []string{ + string(CopyOptionsCreateCopy), + string(CopyOptionsFailOnConflict), + string(CopyOptionsInvalid), + string(CopyOptionsOverwrite), + string(CopyOptionsSkip), + } +} + +func parseCopyOptions(input string) (*CopyOptions, error) { + vals := map[string]CopyOptions{ + "createcopy": CopyOptionsCreateCopy, + "failonconflict": CopyOptionsFailOnConflict, + "invalid": CopyOptionsInvalid, + "overwrite": CopyOptionsOverwrite, + "skip": CopyOptionsSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CopyOptions(input) + return &out, nil +} + +type OverwriteOptions string + +const ( + OverwriteOptionsFailOnConflict OverwriteOptions = "FailOnConflict" + OverwriteOptionsInvalid OverwriteOptions = "Invalid" + OverwriteOptionsOverwrite OverwriteOptions = "Overwrite" +) + +func PossibleValuesForOverwriteOptions() []string { + return []string{ + string(OverwriteOptionsFailOnConflict), + string(OverwriteOptionsInvalid), + string(OverwriteOptionsOverwrite), + } +} + +func parseOverwriteOptions(input string) (*OverwriteOptions, error) { + vals := map[string]OverwriteOptions{ + "failonconflict": OverwriteOptionsFailOnConflict, + "invalid": OverwriteOptionsInvalid, + "overwrite": OverwriteOptionsOverwrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverwriteOptions(input) + return &out, nil +} + +type RecoveryMode string + +const ( + RecoveryModeFileRecovery RecoveryMode = "FileRecovery" + RecoveryModeInvalid RecoveryMode = "Invalid" + RecoveryModeRecoveryUsingSnapshot RecoveryMode = "RecoveryUsingSnapshot" + RecoveryModeSnapshotAttach RecoveryMode = "SnapshotAttach" + RecoveryModeSnapshotAttachAndRecover RecoveryMode = "SnapshotAttachAndRecover" + RecoveryModeWorkloadRecovery RecoveryMode = "WorkloadRecovery" +) + +func PossibleValuesForRecoveryMode() []string { + return []string{ + string(RecoveryModeFileRecovery), + string(RecoveryModeInvalid), + string(RecoveryModeRecoveryUsingSnapshot), + string(RecoveryModeSnapshotAttach), + string(RecoveryModeSnapshotAttachAndRecover), + string(RecoveryModeWorkloadRecovery), + } +} + +func parseRecoveryMode(input string) (*RecoveryMode, error) { + vals := map[string]RecoveryMode{ + "filerecovery": RecoveryModeFileRecovery, + "invalid": RecoveryModeInvalid, + "recoveryusingsnapshot": RecoveryModeRecoveryUsingSnapshot, + "snapshotattach": RecoveryModeSnapshotAttach, + "snapshotattachandrecover": RecoveryModeSnapshotAttachAndRecover, + "workloadrecovery": RecoveryModeWorkloadRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryMode(input) + return &out, nil +} + +type RecoveryType string + +const ( + RecoveryTypeAlternateLocation RecoveryType = "AlternateLocation" + RecoveryTypeInvalid RecoveryType = "Invalid" + RecoveryTypeOffline RecoveryType = "Offline" + RecoveryTypeOriginalLocation RecoveryType = "OriginalLocation" + RecoveryTypeRestoreDisks RecoveryType = "RestoreDisks" +) + +func PossibleValuesForRecoveryType() []string { + return []string{ + string(RecoveryTypeAlternateLocation), + string(RecoveryTypeInvalid), + string(RecoveryTypeOffline), + string(RecoveryTypeOriginalLocation), + string(RecoveryTypeRestoreDisks), + } +} + +func parseRecoveryType(input string) (*RecoveryType, error) { + vals := map[string]RecoveryType{ + "alternatelocation": RecoveryTypeAlternateLocation, + "invalid": RecoveryTypeInvalid, + "offline": RecoveryTypeOffline, + "originallocation": RecoveryTypeOriginalLocation, + "restoredisks": RecoveryTypeRestoreDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryType(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityStandard), + } +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} + +type RestoreRequestType string + +const ( + RestoreRequestTypeFullShareRestore RestoreRequestType = "FullShareRestore" + RestoreRequestTypeInvalid RestoreRequestType = "Invalid" + RestoreRequestTypeItemLevelRestore RestoreRequestType = "ItemLevelRestore" +) + +func PossibleValuesForRestoreRequestType() []string { + return []string{ + string(RestoreRequestTypeFullShareRestore), + string(RestoreRequestTypeInvalid), + string(RestoreRequestTypeItemLevelRestore), + } +} + +func parseRestoreRequestType(input string) (*RestoreRequestType, error) { + vals := map[string]RestoreRequestType{ + "fullsharerestore": RestoreRequestTypeFullShareRestore, + "invalid": RestoreRequestTypeInvalid, + "itemlevelrestore": RestoreRequestTypeItemLevelRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreRequestType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} + +type TargetDiskNetworkAccessOption string + +const ( + TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePrivateAccessForAllDisks" + TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePublicAccessForAllDisks" + TargetDiskNetworkAccessOptionSameAsOnSourceDisks TargetDiskNetworkAccessOption = "SameAsOnSourceDisks" +) + +func PossibleValuesForTargetDiskNetworkAccessOption() []string { + return []string{ + string(TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks), + string(TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks), + string(TargetDiskNetworkAccessOptionSameAsOnSourceDisks), + } +} + +func parseTargetDiskNetworkAccessOption(input string) (*TargetDiskNetworkAccessOption, error) { + vals := map[string]TargetDiskNetworkAccessOption{ + "enableprivateaccessforalldisks": TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks, + "enablepublicaccessforalldisks": TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks, + "sameasonsourcedisks": TargetDiskNetworkAccessOptionSameAsOnSourceDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetDiskNetworkAccessOption(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/id_vault.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/id_vault.go new file mode 100644 index 00000000000..39334989e8a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/id_vault.go @@ -0,0 +1,130 @@ +package validateoperation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return 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", "vaultName"), + } +} + +// 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/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/id_vault_test.go new file mode 100644 index 00000000000..bac4c9d026d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/id_vault_test.go @@ -0,0 +1,282 @@ +package validateoperation + +import ( + "testing" + + "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{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/method_trigger_autorest.go new file mode 100644 index 00000000000..1255fd9377e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/method_trigger_autorest.go @@ -0,0 +1,79 @@ +package validateoperation + +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 TriggerOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Trigger ... +func (c ValidateOperationClient) Trigger(ctx context.Context, id VaultId, input ValidateOperationRequestResource) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "validateoperation.ValidateOperationClient", "Trigger", nil, "Failure preparing request") + return + } + + result, err = c.senderForTrigger(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "validateoperation.ValidateOperationClient", "Trigger", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// TriggerThenPoll performs Trigger then polls until it's completed +func (c ValidateOperationClient) TriggerThenPoll(ctx context.Context, id VaultId, input ValidateOperationRequestResource) error { + result, err := c.Trigger(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Trigger: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Trigger: %+v", err) + } + + return nil +} + +// preparerForTrigger prepares the Trigger request. +func (c ValidateOperationClient) preparerForTrigger(ctx context.Context, id VaultId, input ValidateOperationRequestResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupTriggerValidateOperation", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForTrigger sends the Trigger request. The method will close the +// http.Response Body if it receives an error. +func (c ValidateOperationClient) senderForTrigger(ctx context.Context, req *http.Request) (future TriggerOperationResponse, 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/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..f5b6c3551e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azurefilesharerestorerequest.go @@ -0,0 +1,57 @@ +package validateoperation + +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 _ RestoreRequest = AzureFileShareRestoreRequest{} + +type AzureFileShareRestoreRequest struct { + CopyOptions *CopyOptions `json:"copyOptions,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + RestoreFileSpecs *[]RestoreFileSpecs `json:"restoreFileSpecs,omitempty"` + RestoreRequestType *RestoreRequestType `json:"restoreRequestType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetDetails *TargetAFSRestoreInfo `json:"targetDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureFileShareRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureFileShareRestoreRequest{} + +func (s AzureFileShareRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureFileShareRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..e495e96b4a5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,61 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadPointInTimeRestoreRequest{} + +type AzureWorkloadPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRestoreRequest{} + +func (s AzureWorkloadPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..d084e2d68e8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadrestorerequest.go @@ -0,0 +1,60 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadRestoreRequest{} + +type AzureWorkloadRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadRestoreRequest{} + +func (s AzureWorkloadRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..431629e9037 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,61 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..fc703d110d4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,62 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..9a04045edc5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,60 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadSAPHanaRestoreRequest{} + +type AzureWorkloadSAPHanaRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreRequest{} + +func (s AzureWorkloadSAPHanaRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..07a81c26bcd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,61 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaRestoreWithRehydrateRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..5aa091ec43e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,64 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreRequest{} + +type AzureWorkloadSQLPointInTimeRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..cf33c6bd871 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,65 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..abd5baf76e0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,63 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadSQLRestoreRequest{} + +type AzureWorkloadSQLRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreRequest{} + +func (s AzureWorkloadSQLRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..9624c1d0c0f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,64 @@ +package validateoperation + +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 _ RestoreRequest = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + decoded["objectType"] = "AzureWorkloadSQLRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_encryptiondetails.go new file mode 100644 index 00000000000..d2830fa3e2f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_encryptiondetails.go @@ -0,0 +1,12 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionDetails struct { + EncryptionEnabled *bool `json:"encryptionEnabled,omitempty"` + KekURL *string `json:"kekUrl,omitempty"` + KekVaultId *string `json:"kekVaultId,omitempty"` + SecretKeyURL *string `json:"secretKeyUrl,omitempty"` + SecretKeyVaultId *string `json:"secretKeyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_extendedlocation.go new file mode 100644 index 00000000000..608d19191a4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_extendedlocation.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..81d88980dc3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_iaasvmrestorerequest.go @@ -0,0 +1,76 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreRequest{} + +type IaasVMRestoreRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s IaasVMRestoreRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = IaasVMRestoreRequest{} + +func (s IaasVMRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreRequest: %+v", err) + } + + decoded["objectType"] = "IaasVMRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..b5fff836253 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,77 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreWithRehydrationRequest{} + +type IaasVMRestoreWithRehydrationRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s IaasVMRestoreWithRehydrationRequest) RestoreRequest() BaseRestoreRequestImpl { + return BaseRestoreRequestImpl{ + ObjectType: s.ObjectType, + ResourceGuardOperationRequests: s.ResourceGuardOperationRequests, + } +} + +var _ json.Marshaler = IaasVMRestoreWithRehydrationRequest{} + +func (s IaasVMRestoreWithRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreWithRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + decoded["objectType"] = "IaasVMRestoreWithRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..d804db396e3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_identitybasedrestoredetails.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityBasedRestoreDetails struct { + ObjectType *string `json:"objectType,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_identityinfo.go new file mode 100644 index 00000000000..71e633fc3ea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_identityinfo.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityInfo struct { + IsSystemAssignedIdentity *bool `json:"isSystemAssignedIdentity,omitempty"` + ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..9f5b85e6ad0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_recoverypointrehydrationinfo.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointRehydrationInfo struct { + RehydrationPriority *RehydrationPriority `json:"rehydrationPriority,omitempty"` + RehydrationRetentionDuration *string `json:"rehydrationRetentionDuration,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_restorefilespecs.go new file mode 100644 index 00000000000..f850cae1f62 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_restorefilespecs.go @@ -0,0 +1,10 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFileSpecs struct { + FileSpecType *string `json:"fileSpecType,omitempty"` + Path *string `json:"path,omitempty"` + TargetFolderPath *string `json:"targetFolderPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_restorerequest.go new file mode 100644 index 00000000000..2411117fb0b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_restorerequest.go @@ -0,0 +1,172 @@ +package validateoperation + +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 RestoreRequest interface { + RestoreRequest() BaseRestoreRequestImpl +} + +var _ RestoreRequest = BaseRestoreRequestImpl{} + +type BaseRestoreRequestImpl struct { + ObjectType string `json:"objectType"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +func (s BaseRestoreRequestImpl) RestoreRequest() BaseRestoreRequestImpl { + return s +} + +var _ RestoreRequest = RawRestoreRequestImpl{} + +// RawRestoreRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRestoreRequestImpl struct { + restoreRequest BaseRestoreRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawRestoreRequestImpl) RestoreRequest() BaseRestoreRequestImpl { + return s.restoreRequest +} + +func UnmarshalRestoreRequestImplementation(input []byte) (RestoreRequest, 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 RestoreRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureFileShareRestoreRequest") { + var out AzureFileShareRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRestoreRequest") { + var out AzureWorkloadPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRestoreRequest") { + var out AzureWorkloadRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreRequest") { + var out AzureWorkloadSAPHanaRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreRequest") { + var out AzureWorkloadSQLPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreRequest") { + var out AzureWorkloadSQLRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreRequest") { + var out IaasVMRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreWithRehydrationRequest") { + var out IaasVMRestoreWithRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreWithRehydrationRequest: %+v", err) + } + return out, nil + } + + var parent BaseRestoreRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRestoreRequestImpl: %+v", err) + } + + return RawRestoreRequestImpl{ + restoreRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_securedvmdetails.go new file mode 100644 index 00000000000..d6bbd38ddcc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_securedvmdetails.go @@ -0,0 +1,8 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuredVMDetails struct { + SecuredVMOsDiskEncryptionSetId *string `json:"securedVMOsDiskEncryptionSetId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..f9a96fc887b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_snapshotrestoreparameters.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreParameters struct { + LogPointInTimeForDBRecovery *string `json:"logPointInTimeForDBRecovery,omitempty"` + SkipAttachAndMount *bool `json:"skipAttachAndMount,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..3d7ad759e25 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_sqldatadirectorymapping.go @@ -0,0 +1,11 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectoryMapping struct { + MappingType *SQLDataDirectoryType `json:"mappingType,omitempty"` + SourceLogicalName *string `json:"sourceLogicalName,omitempty"` + SourcePath *string `json:"sourcePath,omitempty"` + TargetPath *string `json:"targetPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..32d155ab051 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetafsrestoreinfo.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetAFSRestoreInfo struct { + Name *string `json:"name,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..9185ea14d0c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetdisknetworkaccesssettings.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetDiskNetworkAccessSettings struct { + TargetDiskAccessId *string `json:"targetDiskAccessId,omitempty"` + TargetDiskNetworkAccessOption *TargetDiskNetworkAccessOption `json:"targetDiskNetworkAccessOption,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetrestoreinfo.go new file mode 100644 index 00000000000..03ec88a3e93 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_targetrestoreinfo.go @@ -0,0 +1,11 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetRestoreInfo struct { + ContainerId *string `json:"containerId,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + OverwriteOption *OverwriteOptions `json:"overwriteOption,omitempty"` + TargetDirectoryForFileRestore *string `json:"targetDirectoryForFileRestore,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..572eae60d18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..b8d3bbe00a1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go new file mode 100644 index 00000000000..9aad5503fcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go @@ -0,0 +1,78 @@ +package validateoperation + +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 _ ValidateOperationRequest = ValidateIaasVMRestoreOperationRequest{} + +type ValidateIaasVMRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest + + ObjectType string `json:"objectType"` +} + +func (s ValidateIaasVMRestoreOperationRequest) ValidateOperationRequest() BaseValidateOperationRequestImpl { + return BaseValidateOperationRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = ValidateIaasVMRestoreOperationRequest{} + +func (s ValidateIaasVMRestoreOperationRequest) MarshalJSON() ([]byte, error) { + type wrapper ValidateIaasVMRestoreOperationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + decoded["objectType"] = "ValidateIaasVMRestoreOperationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ValidateIaasVMRestoreOperationRequest{} + +func (s *ValidateIaasVMRestoreOperationRequest) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ObjectType string `json:"objectType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ObjectType = decoded.ObjectType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateIaasVMRestoreOperationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequest"]; ok { + impl, err := UnmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequest' for 'ValidateIaasVMRestoreOperationRequest': %+v", err) + } + s.RestoreRequest = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateoperationrequest.go new file mode 100644 index 00000000000..76b3eab7f02 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateoperationrequest.go @@ -0,0 +1,83 @@ +package validateoperation + +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 ValidateOperationRequest interface { + ValidateOperationRequest() BaseValidateOperationRequestImpl +} + +var _ ValidateOperationRequest = BaseValidateOperationRequestImpl{} + +type BaseValidateOperationRequestImpl struct { + ObjectType string `json:"objectType"` +} + +func (s BaseValidateOperationRequestImpl) ValidateOperationRequest() BaseValidateOperationRequestImpl { + return s +} + +var _ ValidateOperationRequest = RawValidateOperationRequestImpl{} + +// RawValidateOperationRequestImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawValidateOperationRequestImpl struct { + validateOperationRequest BaseValidateOperationRequestImpl + Type string + Values map[string]interface{} +} + +func (s RawValidateOperationRequestImpl) ValidateOperationRequest() BaseValidateOperationRequestImpl { + return s.validateOperationRequest +} + +func UnmarshalValidateOperationRequestImplementation(input []byte) (ValidateOperationRequest, 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 ValidateOperationRequest into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["objectType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "ValidateIaasVMRestoreOperationRequest") { + var out ValidateIaasVMRestoreOperationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ValidateIaasVMRestoreOperationRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ValidateRestoreOperationRequest") { + var out ValidateRestoreOperationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ValidateRestoreOperationRequest: %+v", err) + } + return out, nil + } + + var parent BaseValidateOperationRequestImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseValidateOperationRequestImpl: %+v", err) + } + + return RawValidateOperationRequestImpl{ + validateOperationRequest: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateoperationrequestresource.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateoperationrequestresource.go new file mode 100644 index 00000000000..14096fc04d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validateoperationrequestresource.go @@ -0,0 +1,42 @@ +package validateoperation + +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 ValidateOperationRequestResource struct { + Id string `json:"id"` + Properties ValidateOperationRequest `json:"properties"` +} + +var _ json.Unmarshaler = &ValidateOperationRequestResource{} + +func (s *ValidateOperationRequestResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id string `json:"id"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateOperationRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalValidateOperationRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ValidateOperationRequestResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validaterestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validaterestoreoperationrequest.go new file mode 100644 index 00000000000..e185e9268f1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/model_validaterestoreoperationrequest.go @@ -0,0 +1,78 @@ +package validateoperation + +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 _ ValidateOperationRequest = ValidateRestoreOperationRequest{} + +type ValidateRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest + + ObjectType string `json:"objectType"` +} + +func (s ValidateRestoreOperationRequest) ValidateOperationRequest() BaseValidateOperationRequestImpl { + return BaseValidateOperationRequestImpl{ + ObjectType: s.ObjectType, + } +} + +var _ json.Marshaler = ValidateRestoreOperationRequest{} + +func (s ValidateRestoreOperationRequest) MarshalJSON() ([]byte, error) { + type wrapper ValidateRestoreOperationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ValidateRestoreOperationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateRestoreOperationRequest: %+v", err) + } + + decoded["objectType"] = "ValidateRestoreOperationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ValidateRestoreOperationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ValidateRestoreOperationRequest{} + +func (s *ValidateRestoreOperationRequest) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ObjectType string `json:"objectType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ObjectType = decoded.ObjectType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateRestoreOperationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequest"]; ok { + impl, err := UnmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequest' for 'ValidateRestoreOperationRequest': %+v", err) + } + s.RestoreRequest = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/version.go b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/version.go new file mode 100644 index 00000000000..40edf217f6f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-10-01/validateoperation/version.go @@ -0,0 +1,10 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/validateoperation/2024-10-01" +}