From f606463e5984dc570e7363240982f921e3ce04a9 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Mon, 8 Apr 2024 08:43:06 +0000 Subject: [PATCH] Updating based on f3c31f1a --- .../2024-02-01/backupengines/README.md | 53 ++ .../2024-02-01/backupengines/client.go | 18 + .../2024-02-01/backupengines/constants.go | 86 ++++ .../backupengines/id_backupengine.go | 134 +++++ .../backupengines/id_backupengine_test.go | 327 +++++++++++++ .../2024-02-01/backupengines/id_vault.go | 125 +++++ .../2024-02-01/backupengines/id_vault_test.go | 282 +++++++++++ .../backupengines/method_get_autorest.go | 97 ++++ .../backupengines/method_list_autorest.go | 215 ++++++++ .../model_azurebackupserverengine.go | 52 ++ .../backupengines/model_backupenginebase.go | 61 +++ .../model_backupenginebaseresource.go | 50 ++ .../model_backupengineextendedinfo.go | 33 ++ .../backupengines/model_dpmbackupengine.go | 52 ++ .../2024-02-01/backupengines/predicates.go | 37 ++ .../2024-02-01/backupengines/version.go | 12 + .../2024-02-01/backupjobs/README.md | 37 ++ .../2024-02-01/backupjobs/client.go | 18 + .../2024-02-01/backupjobs/constants.go | 223 +++++++++ .../2024-02-01/backupjobs/id_vault.go | 125 +++++ .../2024-02-01/backupjobs/id_vault_test.go | 282 +++++++++++ .../backupjobs/method_list_autorest.go | 215 ++++++++ .../backupjobs/model_azureiaasvmerrorinfo.go | 11 + .../backupjobs/model_azureiaasvmjob.go | 81 +++ .../model_azureiaasvmjobextendedinfo.go | 13 + .../model_azureiaasvmjobtaskdetails.go | 45 ++ .../backupjobs/model_azureiaasvmjobv2.go | 80 +++ .../backupjobs/model_azurestorageerrorinfo.go | 10 + .../backupjobs/model_azurestoragejob.go | 81 +++ .../model_azurestoragejobextendedinfo.go | 10 + .../model_azurestoragejobtaskdetails.go | 9 + .../model_azureworkloaderrorinfo.go | 12 + .../backupjobs/model_azureworkloadjob.go | 79 +++ .../model_azureworkloadjobextendedinfo.go | 10 + .../model_azureworkloadjobtaskdetails.go | 9 + .../backupjobs/model_dpmerrorinfo.go | 9 + .../2024-02-01/backupjobs/model_dpmjob.go | 82 ++++ .../backupjobs/model_dpmjobextendedinfo.go | 10 + .../backupjobs/model_dpmjobtaskdetails.go | 42 ++ .../2024-02-01/backupjobs/model_job.go | 101 ++++ .../backupjobs/model_jobresource.go | 50 ++ .../backupjobs/model_maberrorinfo.go | 9 + .../2024-02-01/backupjobs/model_mabjob.go | 81 +++ .../backupjobs/model_mabjobextendedinfo.go | 10 + .../backupjobs/model_mabjobtaskdetails.go | 42 ++ .../2024-02-01/backupjobs/model_vaultjob.go | 78 +++ .../backupjobs/model_vaultjoberrorinfo.go | 10 + .../backupjobs/model_vaultjobextendedinfo.go | 8 + .../2024-02-01/backupjobs/predicates.go | 37 ++ .../2024-02-01/backupjobs/version.go | 12 + .../2024-02-01/backuppolicies/README.md | 37 ++ .../2024-02-01/backuppolicies/client.go | 18 + .../2024-02-01/backuppolicies/constants.go | 458 +++++++++++++++++ .../2024-02-01/backuppolicies/id_vault.go | 125 +++++ .../backuppolicies/id_vault_test.go | 282 +++++++++++ .../backuppolicies/method_list_autorest.go | 215 ++++++++ .../model_azurefileshareprotectionpolicy.go | 85 ++++ .../model_azureiaasvmprotectionpolicy.go | 91 ++++ .../model_azuresqlprotectionpolicy.go | 70 +++ .../model_azurevmworkloadprotectionpolicy.go | 46 ++ .../model_dailyretentionformat.go | 8 + .../model_dailyretentionschedule.go | 9 + .../backuppolicies/model_dailyschedule.go | 8 + .../2024-02-01/backuppolicies/model_day.go | 9 + .../model_genericprotectionpolicy.go | 45 ++ .../backuppolicies/model_hourlyschedule.go | 28 ++ .../model_instantrpadditionaldetails.go | 9 + .../backuppolicies/model_logschedulepolicy.go | 41 ++ .../model_longtermretentionpolicy.go | 44 ++ .../model_longtermschedulepolicy.go | 40 ++ .../model_mabprotectionpolicy.go | 79 +++ .../model_monthlyretentionschedule.go | 12 + .../backuppolicies/model_protectionpolicy.go | 93 ++++ .../model_protectionpolicyresource.go | 50 ++ .../backuppolicies/model_retentionduration.go | 9 + .../backuppolicies/model_retentionpolicy.go | 61 +++ .../backuppolicies/model_schedulepolicy.go | 77 +++ .../backuppolicies/model_settings.go | 10 + .../model_simpleretentionpolicy.go | 41 ++ .../model_simpleschedulepolicy.go | 45 ++ .../model_simpleschedulepolicyv2.go | 44 ++ .../model_snapshotbackupadditionaldetails.go | 10 + .../model_subprotectionpolicy.go | 53 ++ .../backuppolicies/model_tieringpolicy.go | 10 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + .../model_vaultretentionpolicy.go | 40 ++ .../model_weeklyretentionformat.go | 9 + .../model_weeklyretentionschedule.go | 10 + .../backuppolicies/model_weeklyschedule.go | 9 + .../model_yearlyretentionschedule.go | 13 + .../2024-02-01/backuppolicies/predicates.go | 37 ++ .../2024-02-01/backuppolicies/version.go | 12 + .../backupprotectableitems/README.md | 37 ++ .../backupprotectableitems/client.go | 18 + .../backupprotectableitems/constants.go | 105 ++++ .../backupprotectableitems/id_vault.go | 125 +++++ .../backupprotectableitems/id_vault_test.go | 282 +++++++++++ .../method_list_autorest.go | 215 ++++++++ .../model_azurefileshareprotectableitem.go | 47 ++ ...zureiaasclassiccomputevmprotectableitem.go | 47 ++ ...model_azureiaascomputevmprotectableitem.go | 47 ++ .../model_azurevmworkloadprotectableitem.go | 53 ++ ...revmworkloadsapasesystemprotectableitem.go | 53 ++ ...mworkloadsaphanadatabaseprotectableitem.go | 53 ++ .../model_azurevmworkloadsaphanadbinstance.go | 53 ++ ...zurevmworkloadsaphanahsrprotectableitem.go | 53 ++ ...evmworkloadsaphanasystemprotectableitem.go | 53 ++ ...loadsqlavailabilitygroupprotectableitem.go | 54 ++ ...urevmworkloadsqldatabaseprotectableitem.go | 53 ++ ...urevmworkloadsqlinstanceprotectableitem.go | 53 ++ .../model_distributednodesinfo.go | 11 + .../model_errordetail.go | 10 + .../model_iaasvmprotectableitem.go | 47 ++ .../model_prebackupvalidation.go | 10 + .../model_workloadprotectableitem.go | 149 ++++++ .../model_workloadprotectableitemresource.go | 50 ++ .../backupprotectableitems/predicates.go | 37 ++ .../backupprotectableitems/version.go | 12 + .../2024-02-01/backupprotecteditems/README.md | 37 ++ .../2024-02-01/backupprotecteditems/client.go | 18 + .../backupprotecteditems/constants.go | 387 +++++++++++++++ .../backupprotecteditems/id_vault.go | 125 +++++ .../backupprotecteditems/id_vault_test.go | 282 +++++++++++ .../method_list_autorest.go | 215 ++++++++ .../model_azurefileshareprotecteditem.go | 92 ++++ ...azurefileshareprotecteditemextendedinfo.go | 42 ++ ..._azureiaasclassiccomputevmprotecteditem.go | 97 ++++ .../model_azureiaascomputevmprotecteditem.go | 97 ++++ .../model_azureiaasvmprotecteditem.go | 97 ++++ ...el_azureiaasvmprotecteditemextendedinfo.go | 67 +++ .../model_azuresqlprotecteditem.go | 88 ++++ ...model_azuresqlprotecteditemextendedinfo.go | 28 ++ .../model_azurevmworkloadprotecteditem.go | 99 ++++ ...zurevmworkloadprotecteditemextendedinfo.go | 68 +++ ...revmworkloadsapasedatabaseprotecteditem.go | 99 ++++ ...evmworkloadsaphanadatabaseprotecteditem.go | 99 ++++ ...mworkloadsaphanadbinstanceprotecteditem.go | 99 ++++ ...azurevmworkloadsqldatabaseprotecteditem.go | 99 ++++ .../model_diskexclusionproperties.go | 9 + .../model_distributednodesinfo.go | 11 + .../model_dpmprotecteditem.go | 89 ++++ .../model_dpmprotecteditemextendedinfo.go | 75 +++ .../backupprotecteditems/model_errordetail.go | 10 + .../model_extendedproperties.go | 9 + .../model_genericprotecteditem.go | 91 ++++ .../model_kpiresourcehealthdetails.go | 9 + .../model_mabfilefolderprotecteditem.go | 92 ++++ ..._mabfilefolderprotecteditemextendedinfo.go | 40 ++ .../model_protecteditem.go | 149 ++++++ .../model_protecteditemresource.go | 50 ++ .../model_resourcehealthdetails.go | 11 + .../backupprotecteditems/predicates.go | 37 ++ .../backupprotecteditems/version.go | 12 + .../backupprotectioncontainers/README.md | 37 ++ .../backupprotectioncontainers/client.go | 18 + .../backupprotectioncontainers/constants.go | 330 +++++++++++++ .../backupprotectioncontainers/id_vault.go | 125 +++++ .../id_vault_test.go | 282 +++++++++++ .../method_list_autorest.go | 215 ++++++++ .../model_azurebackupservercontainer.go | 53 ++ ...odel_azureiaasclassiccomputevmcontainer.go | 48 ++ .../model_azureiaascomputevmcontainer.go | 48 ++ ...lagworkloadcontainerprotectioncontainer.go | 50 ++ .../model_azuresqlcontainer.go | 45 ++ .../model_azurestoragecontainer.go | 50 ++ ..._azurevmappcontainerprotectioncontainer.go | 50 ++ .../model_azureworkloadcontainer.go | 50 ++ ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 53 ++ .../model_dpmcontainerextendedinfo.go | 26 + .../model_errordetail.go | 10 + .../model_genericcontainer.go | 47 ++ .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 48 ++ .../model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 52 ++ .../model_mabcontainerextendedinfo.go | 30 ++ .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 141 ++++++ .../model_protectioncontainerresource.go | 50 ++ .../model_workloadinquirydetails.go | 10 + .../backupprotectioncontainers/predicates.go | 37 ++ .../backupprotectioncontainers/version.go | 12 + .../backupprotectionintent/README.md | 37 ++ .../backupprotectionintent/client.go | 18 + .../backupprotectionintent/constants.go | 178 +++++++ .../backupprotectionintent/id_vault.go | 125 +++++ .../backupprotectionintent/id_vault_test.go | 282 +++++++++++ .../method_list_autorest.go | 215 ++++++++ ...urerecoveryservicevaultprotectionintent.go | 45 ++ .../model_azureresourceprotectionintent.go | 46 ++ ...model_azureworkloadautoprotectionintent.go | 45 ++ ...reworkloadcontainerautoprotectionintent.go | 45 ++ ...el_azureworkloadsqlautoprotectionintent.go | 46 ++ .../model_protectionintent.go | 85 ++++ .../model_protectionintentresource.go | 50 ++ .../backupprotectionintent/predicates.go | 37 ++ .../backupprotectionintent/version.go | 12 + .../backupresourceencryptionconfigs/README.md | 57 +++ .../backupresourceencryptionconfigs/client.go | 18 + .../constants.go | 114 +++++ .../id_vault.go | 125 +++++ .../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 | 12 + .../README.md | 78 +++ .../client.go | 18 + .../constants.go | 136 ++++++ .../id_vault.go | 125 +++++ .../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 | 12 + .../backupresourcevaultconfigs/README.md | 78 +++ .../backupresourcevaultconfigs/client.go | 18 + .../backupresourcevaultconfigs/constants.go | 139 ++++++ .../backupresourcevaultconfigs/id_vault.go | 125 +++++ .../id_vault_test.go | 282 +++++++++++ .../method_get_autorest.go | 69 +++ .../method_put_autorest.go | 70 +++ .../method_update_autorest.go | 70 +++ .../model_backupresourcevaultconfig.go | 15 + ...model_backupresourcevaultconfigresource.go | 14 + .../backupresourcevaultconfigs/version.go | 12 + .../2024-02-01/backups/README.md | 41 ++ .../2024-02-01/backups/client.go | 18 + .../2024-02-01/backups/constants.go | 52 ++ .../2024-02-01/backups/id_protecteditem.go | 152 ++++++ .../backups/id_protecteditem_test.go | 417 ++++++++++++++++ .../backups/method_trigger_autorest.go | 68 +++ .../model_azurefilesharebackuprequest.go | 41 ++ .../model_azureworkloadbackuprequest.go | 43 ++ .../2024-02-01/backups/model_backuprequest.go | 69 +++ .../backups/model_backuprequestresource.go | 50 ++ .../backups/model_iaasvmbackuprequest.go | 41 ++ .../2024-02-01/backups/version.go | 12 + .../2024-02-01/backupstatus/README.md | 41 ++ .../2024-02-01/backupstatus/client.go | 18 + .../2024-02-01/backupstatus/constants.go | 169 +++++++ .../2024-02-01/backupstatus/id_location.go | 116 +++++ .../backupstatus/id_location_test.go | 237 +++++++++ .../backupstatus/method_get_autorest.go | 70 +++ .../backupstatus/model_backupstatusrequest.go | 10 + .../model_backupstatusresponse.go | 18 + .../2024-02-01/backupstatus/version.go | 12 + .../2024-02-01/backupusagesummaries/README.md | 36 ++ .../2024-02-01/backupusagesummaries/client.go | 18 + .../backupusagesummaries/constants.go | 46 ++ .../backupusagesummaries/id_vault.go | 125 +++++ .../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 | 12 + .../2024-02-01/backupworkloaditems/README.md | 37 ++ .../2024-02-01/backupworkloaditems/client.go | 18 + .../backupworkloaditems/constants.go | 74 +++ .../id_protectioncontainer.go | 143 ++++++ .../id_protectioncontainer_test.go | 372 ++++++++++++++ .../method_list_autorest.go | 215 ++++++++ .../model_azurevmworkloaditem.go | 49 ++ ...urevmworkloadsapasedatabaseworkloaditem.go | 49 ++ ...azurevmworkloadsapasesystemworkloaditem.go | 49 ++ ...revmworkloadsaphanadatabaseworkloaditem.go | 49 ++ ...zurevmworkloadsaphanasystemworkloaditem.go | 49 ++ ..._azurevmworkloadsqldatabaseworkloaditem.go | 49 ++ ..._azurevmworkloadsqlinstanceworkloaditem.go | 50 ++ .../model_sqldatadirectory.go | 10 + .../backupworkloaditems/model_workloaditem.go | 101 ++++ .../model_workloaditemresource.go | 50 ++ .../backupworkloaditems/predicates.go | 37 ++ .../2024-02-01/backupworkloaditems/version.go | 12 + .../2024-02-01/client.go | 239 +++++++++ .../2024-02-01/datamove/README.md | 54 ++ .../2024-02-01/datamove/client.go | 18 + .../2024-02-01/datamove/constants.go | 37 ++ .../2024-02-01/datamove/id_vault.go | 125 +++++ .../2024-02-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-02-01/datamove/version.go | 12 + .../2024-02-01/featuresupport/README.md | 41 ++ .../2024-02-01/featuresupport/client.go | 18 + .../2024-02-01/featuresupport/constants.go | 43 ++ .../2024-02-01/featuresupport/id_location.go | 116 +++++ .../featuresupport/id_location_test.go | 237 +++++++++ .../method_validate_autorest.go | 70 +++ ...el_azurebackupgoalfeaturesupportrequest.go | 40 ++ ...el_azurevmresourcefeaturesupportrequest.go | 42 ++ ...l_azurevmresourcefeaturesupportresponse.go | 8 + .../model_featuresupportrequest.go | 61 +++ .../2024-02-01/featuresupport/version.go | 12 + .../2024-02-01/fetchtieringcost/README.md | 37 ++ .../2024-02-01/fetchtieringcost/client.go | 18 + .../2024-02-01/fetchtieringcost/constants.go | 68 +++ .../2024-02-01/fetchtieringcost/id_vault.go | 125 +++++ .../fetchtieringcost/id_vault_test.go | 282 +++++++++++ .../fetchtieringcost/method_post_autorest.go | 80 +++ ...tchtieringcostinfoforrehydrationrequest.go | 46 ++ .../model_fetchtieringcostinforequest.go | 77 +++ ...htieringcostsavingsinfoforpolicyrequest.go | 43 ++ ...gcostsavingsinfoforprotecteditemrequest.go | 44 ++ ...chtieringcostsavingsinfoforvaultrequest.go | 42 ++ .../fetchtieringcost/model_tieringcostinfo.go | 61 +++ .../model_tieringcostrehydrationinfo.go | 42 ++ .../model_tieringcostsavinginfo.go | 44 ++ .../2024-02-01/fetchtieringcost/version.go | 12 + .../itemlevelrecoveryconnections/README.md | 57 +++ .../itemlevelrecoveryconnections/client.go | 18 + .../id_recoverypoint.go | 161 ++++++ .../id_recoverypoint_test.go | 462 ++++++++++++++++++ .../method_provision_autorest.go | 68 +++ .../method_revoke_autorest.go | 67 +++ ...model_azurefileshareprovisionilrrequest.go | 42 ++ .../model_iaasvmilrregistrationrequest.go | 44 ++ .../model_ilrrequest.go | 61 +++ .../model_ilrrequestresource.go | 50 ++ .../itemlevelrecoveryconnections/version.go | 12 + .../2024-02-01/jobcancellations/client.go | 18 + .../jobcancellations/id_backupjob.go | 134 +++++ .../jobcancellations/id_backupjob_test.go | 327 +++++++++++++ .../method_trigger_autorest.go | 67 +++ .../2024-02-01/jobcancellations/version.go | 12 + .../2024-02-01/jobdetails/README.md | 36 ++ .../2024-02-01/jobdetails/client.go | 18 + .../2024-02-01/jobdetails/constants.go | 223 +++++++++ .../2024-02-01/jobdetails/id_backupjob.go | 134 +++++ .../jobdetails/id_backupjob_test.go | 327 +++++++++++++ .../jobdetails/method_get_autorest.go | 68 +++ .../jobdetails/model_azureiaasvmerrorinfo.go | 11 + .../jobdetails/model_azureiaasvmjob.go | 81 +++ .../model_azureiaasvmjobextendedinfo.go | 13 + .../model_azureiaasvmjobtaskdetails.go | 45 ++ .../jobdetails/model_azureiaasvmjobv2.go | 80 +++ .../jobdetails/model_azurestorageerrorinfo.go | 10 + .../jobdetails/model_azurestoragejob.go | 81 +++ .../model_azurestoragejobextendedinfo.go | 10 + .../model_azurestoragejobtaskdetails.go | 9 + .../model_azureworkloaderrorinfo.go | 12 + .../jobdetails/model_azureworkloadjob.go | 79 +++ .../model_azureworkloadjobextendedinfo.go | 10 + .../model_azureworkloadjobtaskdetails.go | 9 + .../jobdetails/model_dpmerrorinfo.go | 9 + .../2024-02-01/jobdetails/model_dpmjob.go | 82 ++++ .../jobdetails/model_dpmjobextendedinfo.go | 10 + .../jobdetails/model_dpmjobtaskdetails.go | 42 ++ .../2024-02-01/jobdetails/model_job.go | 101 ++++ .../jobdetails/model_jobresource.go | 50 ++ .../jobdetails/model_maberrorinfo.go | 9 + .../2024-02-01/jobdetails/model_mabjob.go | 81 +++ .../jobdetails/model_mabjobextendedinfo.go | 10 + .../jobdetails/model_mabjobtaskdetails.go | 42 ++ .../2024-02-01/jobdetails/model_vaultjob.go | 78 +++ .../jobdetails/model_vaultjoberrorinfo.go | 10 + .../jobdetails/model_vaultjobextendedinfo.go | 8 + .../2024-02-01/jobdetails/version.go | 12 + .../2024-02-01/jobs/client.go | 18 + .../2024-02-01/jobs/id_vault.go | 125 +++++ .../2024-02-01/jobs/id_vault_test.go | 282 +++++++++++ .../2024-02-01/jobs/method_export_autorest.go | 96 ++++ .../2024-02-01/jobs/version.go | 12 + .../2024-02-01/operation/README.md | 41 ++ .../2024-02-01/operation/client.go | 18 + .../2024-02-01/operation/constants.go | 272 +++++++++++ .../2024-02-01/operation/id_vault.go | 125 +++++ .../2024-02-01/operation/id_vault_test.go | 282 +++++++++++ .../operation/method_validate_autorest.go | 70 +++ .../model_azurefilesharerestorerequest.go | 46 ++ ..._azureworkloadpointintimerestorerequest.go | 50 ++ .../model_azureworkloadrestorerequest.go | 49 ++ ...orkloadsaphanapointintimerestorerequest.go | 50 ++ ...apointintimerestorewithrehydraterequest.go | 51 ++ ...odel_azureworkloadsaphanarestorerequest.go | 49 ++ ...kloadsaphanarestorewithrehydraterequest.go | 50 ++ ...ureworkloadsqlpointintimerestorerequest.go | 53 ++ ...lpointintimerestorewithrehydraterequest.go | 54 ++ .../model_azureworkloadsqlrestorerequest.go | 52 ++ ...eworkloadsqlrestorewithrehydraterequest.go | 53 ++ .../operation/model_encryptiondetails.go | 12 + .../2024-02-01/operation/model_errordetail.go | 10 + .../operation/model_extendedlocation.go | 9 + .../operation/model_iaasvmrestorerequest.go | 65 +++ ...del_iaasvmrestorewithrehydrationrequest.go | 66 +++ .../model_identitybasedrestoredetails.go | 9 + .../operation/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../operation/model_restorefilespecs.go | 10 + .../operation/model_restorerequest.go | 149 ++++++ .../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 | 60 +++ .../model_validateoperationrequest.go | 61 +++ .../model_validateoperationrequestresource.go | 40 ++ .../model_validateoperationresponse.go | 8 + .../model_validateoperationsresponse.go | 8 + .../model_validaterestoreoperationrequest.go | 60 +++ .../2024-02-01/operation/version.go | 12 + .../privateendpointconnection/README.md | 65 +++ .../privateendpointconnection/client.go | 18 + .../privateendpointconnection/constants.go | 105 ++++ .../id_privateendpointconnection.go | 134 +++++ .../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 | 12 + .../protectablecontainers/README.md | 37 ++ .../protectablecontainers/client.go | 18 + .../protectablecontainers/constants.go | 131 +++++ .../protectablecontainers/id_backupfabric.go | 134 +++++ .../id_backupfabric_test.go | 327 +++++++++++++ .../method_list_autorest.go | 215 ++++++++ .../model_azurestorageprotectablecontainer.go | 44 ++ ...azurevmappcontainerprotectablecontainer.go | 44 ++ .../model_protectablecontainer.go | 61 +++ .../model_protectablecontainerresource.go | 50 ++ .../protectablecontainers/predicates.go | 37 ++ .../protectablecontainers/version.go | 12 + .../2024-02-01/protecteditems/README.md | 73 +++ .../2024-02-01/protecteditems/client.go | 18 + .../2024-02-01/protecteditems/constants.go | 387 +++++++++++++++ .../protecteditems/id_protecteditem.go | 152 ++++++ .../protecteditems/id_protecteditem_test.go | 417 ++++++++++++++++ .../method_createorupdate_autorest.go | 69 +++ .../protecteditems/method_delete_autorest.go | 66 +++ .../protecteditems/method_get_autorest.go | 97 ++++ .../model_azurefileshareprotecteditem.go | 92 ++++ ...azurefileshareprotecteditemextendedinfo.go | 42 ++ ..._azureiaasclassiccomputevmprotecteditem.go | 97 ++++ .../model_azureiaascomputevmprotecteditem.go | 97 ++++ .../model_azureiaasvmprotecteditem.go | 97 ++++ ...el_azureiaasvmprotecteditemextendedinfo.go | 67 +++ .../model_azuresqlprotecteditem.go | 88 ++++ ...model_azuresqlprotecteditemextendedinfo.go | 28 ++ .../model_azurevmworkloadprotecteditem.go | 99 ++++ ...zurevmworkloadprotecteditemextendedinfo.go | 68 +++ ...revmworkloadsapasedatabaseprotecteditem.go | 99 ++++ ...evmworkloadsaphanadatabaseprotecteditem.go | 99 ++++ ...mworkloadsaphanadbinstanceprotecteditem.go | 99 ++++ ...azurevmworkloadsqldatabaseprotecteditem.go | 99 ++++ .../model_diskexclusionproperties.go | 9 + .../model_distributednodesinfo.go | 11 + .../protecteditems/model_dpmprotecteditem.go | 89 ++++ .../model_dpmprotecteditemextendedinfo.go | 75 +++ .../protecteditems/model_errordetail.go | 10 + .../model_extendedproperties.go | 9 + .../model_genericprotecteditem.go | 91 ++++ .../model_kpiresourcehealthdetails.go | 9 + .../model_mabfilefolderprotecteditem.go | 92 ++++ ..._mabfilefolderprotecteditemextendedinfo.go | 40 ++ .../protecteditems/model_protecteditem.go | 149 ++++++ .../model_protecteditemresource.go | 50 ++ .../model_resourcehealthdetails.go | 11 + .../2024-02-01/protecteditems/version.go | 12 + .../2024-02-01/protectioncontainers/README.md | 101 ++++ .../2024-02-01/protectioncontainers/client.go | 18 + .../protectioncontainers/constants.go | 330 +++++++++++++ .../protectioncontainers/id_backupfabric.go | 134 +++++ .../id_backupfabric_test.go | 327 +++++++++++++ .../id_protectioncontainer.go | 143 ++++++ .../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 | 53 ++ ...odel_azureiaasclassiccomputevmcontainer.go | 48 ++ .../model_azureiaascomputevmcontainer.go | 48 ++ ...lagworkloadcontainerprotectioncontainer.go | 50 ++ .../model_azuresqlcontainer.go | 45 ++ .../model_azurestoragecontainer.go | 50 ++ ..._azurevmappcontainerprotectioncontainer.go | 50 ++ .../model_azureworkloadcontainer.go | 50 ++ ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 53 ++ .../model_dpmcontainerextendedinfo.go | 26 + .../protectioncontainers/model_errordetail.go | 10 + .../model_genericcontainer.go | 47 ++ .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 48 ++ .../protectioncontainers/model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 52 ++ .../model_mabcontainerextendedinfo.go | 30 ++ .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 141 ++++++ .../model_protectioncontainerresource.go | 50 ++ .../model_workloadinquirydetails.go | 10 + .../protectioncontainers/version.go | 12 + .../2024-02-01/protectionintent/README.md | 94 ++++ .../2024-02-01/protectionintent/client.go | 18 + .../2024-02-01/protectionintent/constants.go | 279 +++++++++++ .../id_backupprotectionintent.go | 143 ++++++ .../id_backupprotectionintent_test.go | 372 ++++++++++++++ .../protectionintent/id_location.go | 116 +++++ .../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 | 45 ++ .../model_azureresourceprotectionintent.go | 46 ++ ...model_azureworkloadautoprotectionintent.go | 45 ++ ...reworkloadcontainerautoprotectionintent.go | 45 ++ ...el_azureworkloadsqlautoprotectionintent.go | 46 ++ .../model_prevalidateenablebackuprequest.go | 11 + .../model_prevalidateenablebackupresponse.go | 13 + .../model_protectionintent.go | 85 ++++ .../model_protectionintentresource.go | 50 ++ .../2024-02-01/protectionintent/version.go | 12 + .../2024-02-01/protectionpolicies/README.md | 69 +++ .../2024-02-01/protectionpolicies/client.go | 18 + .../protectionpolicies/constants.go | 458 +++++++++++++++++ .../protectionpolicies/id_backuppolicy.go | 134 +++++ .../id_backuppolicy_test.go | 327 +++++++++++++ .../method_createorupdate_autorest.go | 69 +++ .../method_delete_autorest.go | 78 +++ .../protectionpolicies/method_get_autorest.go | 68 +++ .../model_azurefileshareprotectionpolicy.go | 85 ++++ .../model_azureiaasvmprotectionpolicy.go | 91 ++++ .../model_azuresqlprotectionpolicy.go | 70 +++ .../model_azurevmworkloadprotectionpolicy.go | 46 ++ .../model_dailyretentionformat.go | 8 + .../model_dailyretentionschedule.go | 9 + .../protectionpolicies/model_dailyschedule.go | 8 + .../protectionpolicies/model_day.go | 9 + .../model_genericprotectionpolicy.go | 45 ++ .../model_hourlyschedule.go | 28 ++ .../model_instantrpadditionaldetails.go | 9 + .../model_logschedulepolicy.go | 41 ++ .../model_longtermretentionpolicy.go | 44 ++ .../model_longtermschedulepolicy.go | 40 ++ .../model_mabprotectionpolicy.go | 79 +++ .../model_monthlyretentionschedule.go | 12 + .../model_protectionpolicy.go | 93 ++++ .../model_protectionpolicyresource.go | 50 ++ .../model_retentionduration.go | 9 + .../model_retentionpolicy.go | 61 +++ .../model_schedulepolicy.go | 77 +++ .../protectionpolicies/model_settings.go | 10 + .../model_simpleretentionpolicy.go | 41 ++ .../model_simpleschedulepolicy.go | 45 ++ .../model_simpleschedulepolicyv2.go | 44 ++ .../model_snapshotbackupadditionaldetails.go | 10 + .../model_subprotectionpolicy.go | 53 ++ .../protectionpolicies/model_tieringpolicy.go | 10 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + .../model_vaultretentionpolicy.go | 40 ++ .../model_weeklyretentionformat.go | 9 + .../model_weeklyretentionschedule.go | 10 + .../model_weeklyschedule.go | 9 + .../model_yearlyretentionschedule.go | 13 + .../2024-02-01/protectionpolicies/version.go | 12 + .../2024-02-01/recoverypoint/README.md | 37 ++ .../2024-02-01/recoverypoint/client.go | 18 + .../2024-02-01/recoverypoint/constants.go | 40 ++ .../recoverypoint/id_recoverypoint.go | 161 ++++++ .../recoverypoint/id_recoverypoint_test.go | 462 ++++++++++++++++++ .../method_moverecoverypoint_autorest.go | 79 +++ .../model_moverpacrosstiersrequest.go | 10 + .../2024-02-01/recoverypoint/version.go | 12 + .../2024-02-01/recoverypoints/README.md | 53 ++ .../2024-02-01/recoverypoints/client.go | 18 + .../2024-02-01/recoverypoints/constants.go | 151 ++++++ .../recoverypoints/id_protecteditem.go | 152 ++++++ .../recoverypoints/id_protecteditem_test.go | 417 ++++++++++++++++ .../recoverypoints/id_recoverypoint.go | 161 ++++++ .../recoverypoints/id_recoverypoint_test.go | 462 ++++++++++++++++++ .../recoverypoints/method_get_autorest.go | 68 +++ .../recoverypoints/method_list_autorest.go | 215 ++++++++ .../model_azurefilesharerecoverypoint.go | 45 ++ ...l_azureworkloadpointintimerecoverypoint.go | 46 ++ .../model_azureworkloadrecoverypoint.go | 45 ++ ...workloadsaphanapointintimerecoverypoint.go | 46 ++ ...model_azureworkloadsaphanarecoverypoint.go | 45 ++ ...zureworkloadsqlpointintimerecoverypoint.go | 47 ++ .../model_azureworkloadsqlrecoverypoint.go | 46 ++ ...ureworkloadsqlrecoverypointextendedinfo.go | 27 + .../recoverypoints/model_bekdetails.go | 10 + .../recoverypoints/model_diskinformation.go | 9 + .../recoverypoints/model_extendedlocation.go | 9 + .../model_genericrecoverypoint.go | 45 ++ .../model_iaasvmrecoverypoint.go | 61 +++ .../recoverypoints/model_kekdetails.go | 10 + .../model_keyandsecretdetails.go | 10 + .../recoverypoints/model_pointintimerange.go | 39 ++ .../recoverypoints/model_recoverypoint.go | 117 +++++ .../model_recoverypointdiskconfiguration.go | 11 + .../model_recoverypointmovereadinessinfo.go | 9 + .../model_recoverypointproperties.go | 10 + .../model_recoverypointresource.go | 50 ++ .../model_recoverypointtierinformationv2.go | 10 + .../recoverypoints/model_sqldatadirectory.go | 10 + .../2024-02-01/recoverypoints/predicates.go | 37 ++ .../2024-02-01/recoverypoints/version.go | 12 + .../README.md | 42 ++ .../client.go | 18 + .../constants.go | 151 ++++++ .../id_protecteditem.go | 152 ++++++ .../id_protecteditem_test.go | 417 ++++++++++++++++ .../method_list_autorest.go | 187 +++++++ .../model_azurefilesharerecoverypoint.go | 45 ++ ...l_azureworkloadpointintimerecoverypoint.go | 46 ++ .../model_azureworkloadrecoverypoint.go | 45 ++ ...workloadsaphanapointintimerecoverypoint.go | 46 ++ ...model_azureworkloadsaphanarecoverypoint.go | 45 ++ ...zureworkloadsqlpointintimerecoverypoint.go | 47 ++ .../model_azureworkloadsqlrecoverypoint.go | 46 ++ ...ureworkloadsqlrecoverypointextendedinfo.go | 27 + .../model_bekdetails.go | 10 + .../model_diskinformation.go | 9 + .../model_extendedlocation.go | 9 + .../model_genericrecoverypoint.go | 45 ++ .../model_iaasvmrecoverypoint.go | 61 +++ .../model_kekdetails.go | 10 + .../model_keyandsecretdetails.go | 10 + ...recoverypointsrecommendedformoverequest.go | 9 + .../model_pointintimerange.go | 39 ++ .../model_recoverypoint.go | 117 +++++ .../model_recoverypointdiskconfiguration.go | 11 + .../model_recoverypointmovereadinessinfo.go | 9 + .../model_recoverypointproperties.go | 10 + .../model_recoverypointresource.go | 50 ++ .../model_recoverypointtierinformationv2.go | 10 + .../model_sqldatadirectory.go | 10 + .../predicates.go | 37 ++ .../version.go | 12 + .../2024-02-01/resourceguardproxies/README.md | 37 ++ .../2024-02-01/resourceguardproxies/client.go | 18 + .../resourceguardproxies/id_vault.go | 125 +++++ .../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 | 12 + .../2024-02-01/resourceguardproxy/README.md | 94 ++++ .../2024-02-01/resourceguardproxy/client.go | 18 + .../id_backupresourceguardproxy.go | 134 +++++ .../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-02-01/resourceguardproxy/version.go | 12 + .../2024-02-01/restores/README.md | 37 ++ .../2024-02-01/restores/client.go | 18 + .../2024-02-01/restores/constants.go | 272 +++++++++++ .../2024-02-01/restores/id_recoverypoint.go | 161 ++++++ .../restores/id_recoverypoint_test.go | 462 ++++++++++++++++++ .../restores/method_trigger_autorest.go | 79 +++ .../model_azurefilesharerestorerequest.go | 46 ++ ..._azureworkloadpointintimerestorerequest.go | 50 ++ .../model_azureworkloadrestorerequest.go | 49 ++ ...orkloadsaphanapointintimerestorerequest.go | 50 ++ ...apointintimerestorewithrehydraterequest.go | 51 ++ ...odel_azureworkloadsaphanarestorerequest.go | 49 ++ ...kloadsaphanarestorewithrehydraterequest.go | 50 ++ ...ureworkloadsqlpointintimerestorerequest.go | 53 ++ ...lpointintimerestorewithrehydraterequest.go | 54 ++ .../model_azureworkloadsqlrestorerequest.go | 52 ++ ...eworkloadsqlrestorewithrehydraterequest.go | 53 ++ .../restores/model_encryptiondetails.go | 12 + .../restores/model_extendedlocation.go | 9 + .../restores/model_iaasvmrestorerequest.go | 65 +++ ...del_iaasvmrestorewithrehydrationrequest.go | 66 +++ .../model_identitybasedrestoredetails.go | 9 + .../2024-02-01/restores/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../restores/model_restorefilespecs.go | 10 + .../restores/model_restorerequest.go | 149 ++++++ .../restores/model_restorerequestresource.go | 50 ++ .../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-02-01/restores/version.go | 12 + .../2024-02-01/securitypins/README.md | 41 ++ .../2024-02-01/securitypins/client.go | 18 + .../2024-02-01/securitypins/id_vault.go | 125 +++++ .../2024-02-01/securitypins/id_vault_test.go | 282 +++++++++++ .../securitypins/method_get_autorest.go | 70 +++ .../securitypins/model_securitypinbase.go | 8 + .../securitypins/model_tokeninformation.go | 10 + .../2024-02-01/securitypins/version.go | 12 + .../softdeletedcontainers/README.md | 37 ++ .../softdeletedcontainers/client.go | 18 + .../softdeletedcontainers/constants.go | 330 +++++++++++++ .../softdeletedcontainers/id_vault.go | 125 +++++ .../softdeletedcontainers/id_vault_test.go | 282 +++++++++++ ...eletedprotectioncontainerslist_autorest.go | 215 ++++++++ .../model_azurebackupservercontainer.go | 53 ++ ...odel_azureiaasclassiccomputevmcontainer.go | 48 ++ .../model_azureiaascomputevmcontainer.go | 48 ++ ...lagworkloadcontainerprotectioncontainer.go | 50 ++ .../model_azuresqlcontainer.go | 45 ++ .../model_azurestoragecontainer.go | 50 ++ ..._azurevmappcontainerprotectioncontainer.go | 50 ++ .../model_azureworkloadcontainer.go | 50 ++ ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 53 ++ .../model_dpmcontainerextendedinfo.go | 26 + .../model_errordetail.go | 10 + .../model_genericcontainer.go | 47 ++ .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 48 ++ .../model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 52 ++ .../model_mabcontainerextendedinfo.go | 30 ++ .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 141 ++++++ .../model_protectioncontainerresource.go | 50 ++ .../model_workloadinquirydetails.go | 10 + .../softdeletedcontainers/predicates.go | 37 ++ .../softdeletedcontainers/version.go | 12 + .../2024-02-01/validateoperation/README.md | 37 ++ .../2024-02-01/validateoperation/client.go | 18 + .../2024-02-01/validateoperation/constants.go | 272 +++++++++++ .../2024-02-01/validateoperation/id_vault.go | 125 +++++ .../validateoperation/id_vault_test.go | 282 +++++++++++ .../method_trigger_autorest.go | 79 +++ .../model_azurefilesharerestorerequest.go | 46 ++ ..._azureworkloadpointintimerestorerequest.go | 50 ++ .../model_azureworkloadrestorerequest.go | 49 ++ ...orkloadsaphanapointintimerestorerequest.go | 50 ++ ...apointintimerestorewithrehydraterequest.go | 51 ++ ...odel_azureworkloadsaphanarestorerequest.go | 49 ++ ...kloadsaphanarestorewithrehydraterequest.go | 50 ++ ...ureworkloadsqlpointintimerestorerequest.go | 53 ++ ...lpointintimerestorewithrehydraterequest.go | 54 ++ .../model_azureworkloadsqlrestorerequest.go | 52 ++ ...eworkloadsqlrestorewithrehydraterequest.go | 53 ++ .../model_encryptiondetails.go | 12 + .../model_extendedlocation.go | 9 + .../model_iaasvmrestorerequest.go | 65 +++ ...del_iaasvmrestorewithrehydrationrequest.go | 66 +++ .../model_identitybasedrestoredetails.go | 9 + .../validateoperation/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../model_restorefilespecs.go | 10 + .../validateoperation/model_restorerequest.go | 149 ++++++ .../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 | 60 +++ .../model_validateoperationrequest.go | 61 +++ .../model_validateoperationrequestresource.go | 40 ++ .../model_validaterestoreoperationrequest.go | 60 +++ .../2024-02-01/validateoperation/version.go | 12 + 796 files changed, 54563 insertions(+) create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_backupengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_backupengine_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_azurebackupserverengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupenginebase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupenginebaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupengineextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_dpmbackupengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupengines/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjobv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestorageerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestoragejob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestoragejobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestoragejobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloaderrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloadjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloadjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloadjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_job.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_jobresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_maberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_mabjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_mabjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_mabjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_vaultjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_vaultjoberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_vaultjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azurefileshareprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azureiaasvmprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azuresqlprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_dailyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_dailyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_dailyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_day.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_genericprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_hourlyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_instantrpadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_logschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_longtermretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_longtermschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_mabprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_monthlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_protectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_protectionpolicyresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_retentionduration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_retentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_schedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_settings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleschedulepolicyv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_snapshotbackupadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_subprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_tieringpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_vaultretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_weeklyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_weeklyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_weeklyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_yearlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurefileshareprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_iaasvmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_prebackupvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_workloadprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_workloadprotectableitemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurefileshareprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasvmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azuresqlprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_diskexclusionproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_dpmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_extendedproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_genericprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_kpiresourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_mabfilefolderprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_protecteditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_resourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureresourceprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_protectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_protectionintentresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/model_azurefilesharebackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/model_azureworkloadbackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/model_backuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/model_backuprequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/model_iaasvmbackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backups/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/model_backupstatusrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/model_backupstatusresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/model_backupmanagementusage.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/model_backupmanagementusagelist.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/model_nameinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/id_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/id_protectioncontainer_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_workloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_workloaditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/method_bmspreparedatamove_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/method_bmstriggerdatamove_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/model_preparedatamoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/model_triggerdatamoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/datamove/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_featuresupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/method_post_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostinforequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostsavinginfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/method_provision_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/method_revoke_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_ilrrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_ilrrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/id_backupjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/id_backupjob_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/id_backupjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/id_backupjob_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjobv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestorageerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestoragejob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestoragejobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestoragejobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloaderrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloadjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloadjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloadjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_job.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_jobresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_maberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_mabjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_mabjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_mabjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_vaultjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_vaultjoberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_vaultjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobs/method_export_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/jobs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateiaasvmrestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationsresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validaterestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/operation/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/id_privateendpointconnection.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/id_privateendpointconnection_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/model_privateendpoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/model_privateendpointconnection.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/model_privateendpointconnectionresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/id_backupfabric.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/id_backupfabric_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_azurestorageprotectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_protectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_protectablecontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurefileshareprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaascomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasvmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azuresqlprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_diskexclusionproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_dpmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_dpmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_extendedproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_genericprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_kpiresourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_mabfilefolderprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_protecteditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_resourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_backupfabric.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_backupfabric_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_protectioncontainer_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_inquire_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_refresh_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_register_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_unregister_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_backupprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_backupprotectionintent_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureresourceprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_prevalidateenablebackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_prevalidateenablebackupresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_protectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_protectionintentresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/id_backuppolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/id_backuppolicy_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azurefileshareprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azuresqlprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_dailyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_dailyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_dailyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_day.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_genericprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_hourlyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_instantrpadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_logschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_longtermretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_longtermschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_mabprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_monthlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_protectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_protectionpolicyresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_retentionduration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_retentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_schedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_settings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleschedulepolicyv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_snapshotbackupadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_subprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_tieringpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_vaultretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_weeklyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_weeklyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_weeklyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_yearlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/method_moverecoverypoint_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/model_moverpacrosstiersrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azurefilesharerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_bekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_diskinformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_genericrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_iaasvmrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_kekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_keyandsecretdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_pointintimerange.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointdiskconfiguration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointmovereadinessinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointtierinformationv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_bekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_diskinformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_kekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_pointintimerange.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/model_resourceguardoperationdetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/model_resourceguardproxybase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/model_resourceguardproxybaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/id_backupresourceguardproxy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/id_backupresourceguardproxy_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/method_unlockdelete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_resourceguardoperationdetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_resourceguardproxybase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_resourceguardproxybaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_unlockdeleterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_unlockdeleteresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorerequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/restores/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/securitypins/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/securitypins/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/securitypins/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/securitypins/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/securitypins/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/securitypins/model_securitypinbase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/securitypins/model_tokeninformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/securitypins/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateoperationrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validaterestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/version.go diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/README.md new file mode 100644 index 00000000000..26a283830a6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupengines` Documentation + +The `backupengines` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupEngineValue") + +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", "vaultValue") + +// 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-02-01/backupengines/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/client.go new file mode 100644 index 00000000000..3f415af9d81 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupengines/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/constants.go new file mode 100644 index 00000000000..0b1ec0205b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/constants.go @@ -0,0 +1,86 @@ +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-02-01/backupengines/id_backupengine.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_backupengine.go new file mode 100644 index 00000000000..aac17f29adb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_backupengine.go @@ -0,0 +1,134 @@ +package backupengines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupEngines", "backupEngines", "backupEngines"), + resourceids.UserSpecifiedSegment("backupEngineName", "backupEngineValue"), + } +} + +// 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-02-01/backupengines/id_backupengine_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_backupengine_test.go new file mode 100644 index 00000000000..e3ded7159ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupEngineValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupEngineName != "backupEngineValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupEngineName'", id.BackupEngineName, "backupEngineValue") + } +} + +func TestFormatBackupEngineID(t *testing.T) { + actual := NewBackupEngineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupEngineValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupEngineName: "backupEngineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPeNgInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupEngineName: "backupEngineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue/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/vAuLtVaLuE/bAcKuPeNgInEs/bAcKuPeNgInEvAlUe", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupEngineName: "bAcKuPeNgInEvAlUe", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPeNgInEs/bAcKuPeNgInEvAlUe/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-02-01/backupengines/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_vault.go new file mode 100644 index 00000000000..ef7bbdf5cb7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_vault.go @@ -0,0 +1,125 @@ +package backupengines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/id_vault_test.go new file mode 100644 index 00000000000..1a7a230545a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupengines/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/method_get_autorest.go new file mode 100644 index 00000000000..e4493845ef2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupengines/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/method_list_autorest.go new file mode 100644 index 00000000000..bfc2eb661b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupengines/model_azurebackupserverengine.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_azurebackupserverengine.go new file mode 100644 index 00000000000..af20b6e3719 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_azurebackupserverengine.go @@ -0,0 +1,52 @@ +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"` + 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"` +} + +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-02-01/backupengines/model_backupenginebase.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupenginebase.go new file mode 100644 index 00000000000..d80588db3b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupenginebase.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["backupEngineType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawBackupEngineBaseImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupenginebaseresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupenginebaseresource.go new file mode 100644 index 00000000000..d7eac2e8d35 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupenginebaseresource.go @@ -0,0 +1,50 @@ +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 { + type alias BackupEngineBaseResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into BackupEngineBaseResource: %+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-02-01/backupengines/model_backupengineextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_backupengineextendedinfo.go new file mode 100644 index 00000000000..cf19ed8a259 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupengines/model_dpmbackupengine.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_dpmbackupengine.go new file mode 100644 index 00000000000..5d5df373244 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/model_dpmbackupengine.go @@ -0,0 +1,52 @@ +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"` + 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"` +} + +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-02-01/backupengines/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/predicates.go new file mode 100644 index 00000000000..5d9e2bfd1f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupengines/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/version.go new file mode 100644 index 00000000000..2787ac166cf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupengines/version.go @@ -0,0 +1,12 @@ +package backupengines + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupengines/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/README.md new file mode 100644 index 00000000000..516dfaf28b2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs` Documentation + +The `backupjobs` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +// 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-02-01/backupjobs/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/client.go new file mode 100644 index 00000000000..79d95da7560 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/constants.go new file mode 100644 index 00000000000..15209b39988 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/constants.go @@ -0,0 +1,223 @@ +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-02-01/backupjobs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/id_vault.go new file mode 100644 index 00000000000..67e9492addd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/id_vault.go @@ -0,0 +1,125 @@ +package backupjobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/id_vault_test.go new file mode 100644 index 00000000000..6b0c70de2b6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupjobs/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/method_list_autorest.go new file mode 100644 index 00000000000..81e1c19dc60 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azureiaasvmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmerrorinfo.go new file mode 100644 index 00000000000..d9fe5b31814 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azureiaasvmjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjob.go new file mode 100644 index 00000000000..7bf1b7e0e61 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjob.go @@ -0,0 +1,81 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/backupjobs/model_azureiaasvmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjobextendedinfo.go new file mode 100644 index 00000000000..8fd0ef0f439 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azureiaasvmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjobtaskdetails.go new file mode 100644 index 00000000000..dad4a07a3ba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azureiaasvmjobv2.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjobv2.go new file mode 100644 index 00000000000..8512e3d4550 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureiaasvmjobv2.go @@ -0,0 +1,80 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/backupjobs/model_azurestorageerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestorageerrorinfo.go new file mode 100644 index 00000000000..9a52a41965c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azurestoragejob.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestoragejob.go new file mode 100644 index 00000000000..d0ea1e45479 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestoragejob.go @@ -0,0 +1,81 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/backupjobs/model_azurestoragejobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestoragejobextendedinfo.go new file mode 100644 index 00000000000..22b7d4107d7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azurestoragejobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azurestoragejobtaskdetails.go new file mode 100644 index 00000000000..9b9bb298d99 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azureworkloaderrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloaderrorinfo.go new file mode 100644 index 00000000000..edc953a540c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azureworkloadjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloadjob.go new file mode 100644 index 00000000000..5432c48ce4f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloadjob.go @@ -0,0 +1,79 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/backupjobs/model_azureworkloadjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloadjobextendedinfo.go new file mode 100644 index 00000000000..160a414f7f3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_azureworkloadjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_azureworkloadjobtaskdetails.go new file mode 100644 index 00000000000..0757ffec0fb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_dpmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmerrorinfo.go new file mode 100644 index 00000000000..091cf8f3157 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_dpmjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmjob.go new file mode 100644 index 00000000000..ceabc044801 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmjob.go @@ -0,0 +1,82 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/backupjobs/model_dpmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmjobextendedinfo.go new file mode 100644 index 00000000000..6d4f63a2296 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_dpmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_dpmjobtaskdetails.go new file mode 100644 index 00000000000..ebf8a7cd691 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_job.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_job.go new file mode 100644 index 00000000000..edb0e57dd4a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_job.go @@ -0,0 +1,101 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["jobType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawJobImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_jobresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_jobresource.go new file mode 100644 index 00000000000..cb6a61ab28c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_jobresource.go @@ -0,0 +1,50 @@ +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 { + type alias JobResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into JobResource: %+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-02-01/backupjobs/model_maberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_maberrorinfo.go new file mode 100644 index 00000000000..9c3668d2bd5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_mabjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_mabjob.go new file mode 100644 index 00000000000..d1e4eda593c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_mabjob.go @@ -0,0 +1,81 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/backupjobs/model_mabjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_mabjobextendedinfo.go new file mode 100644 index 00000000000..eb61f914ed9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_mabjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_mabjobtaskdetails.go new file mode 100644 index 00000000000..15efde49be8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_vaultjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_vaultjob.go new file mode 100644 index 00000000000..ac59fa1e242 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_vaultjob.go @@ -0,0 +1,78 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/backupjobs/model_vaultjoberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_vaultjoberrorinfo.go new file mode 100644 index 00000000000..cca822b6d80 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/model_vaultjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/model_vaultjobextendedinfo.go new file mode 100644 index 00000000000..ad9c628fcf1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/predicates.go new file mode 100644 index 00000000000..f8942840380 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupjobs/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/version.go new file mode 100644 index 00000000000..c100d7aeed0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs/version.go @@ -0,0 +1,12 @@ +package backupjobs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupjobs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/README.md new file mode 100644 index 00000000000..d29898b70b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies` Documentation + +The `backuppolicies` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +// 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-02-01/backuppolicies/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/client.go new file mode 100644 index 00000000000..c8b3aad1674 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/constants.go new file mode 100644 index 00000000000..195142cbae0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/constants.go @@ -0,0 +1,458 @@ +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-02-01/backuppolicies/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/id_vault.go new file mode 100644 index 00000000000..b11f519a784 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/id_vault.go @@ -0,0 +1,125 @@ +package backuppolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/id_vault_test.go new file mode 100644 index 00000000000..0dfc82aa97f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backuppolicies/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/method_list_autorest.go new file mode 100644 index 00000000000..094b05fed04 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_azurefileshareprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azurefileshareprotectionpolicy.go new file mode 100644 index 00000000000..b2a087a993d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azurefileshareprotectionpolicy.go @@ -0,0 +1,85 @@ +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 + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureFileShareProtectionPolicy{} + +func (s AzureFileShareProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureStorage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureFileShareProtectionPolicy{} + +func (s *AzureFileShareProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureFileShareProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.TimeZone = decoded.TimeZone + s.VaultRetentionPolicy = decoded.VaultRetentionPolicy + s.WorkLoadType = decoded.WorkLoadType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azureiaasvmprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azureiaasvmprotectionpolicy.go new file mode 100644 index 00000000000..690b63e51c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azureiaasvmprotectionpolicy.go @@ -0,0 +1,91 @@ +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 + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureIaaSVMProtectionPolicy{} + +func (s AzureIaaSVMProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureIaasVM" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureIaaSVMProtectionPolicy{} + +func (s *AzureIaaSVMProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureIaaSVMProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + + s.InstantRPDetails = decoded.InstantRPDetails + s.InstantRpRetentionRangeInDays = decoded.InstantRpRetentionRangeInDays + s.PolicyType = decoded.PolicyType + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.SnapshotConsistencyType = decoded.SnapshotConsistencyType + s.TieringPolicy = decoded.TieringPolicy + s.TimeZone = decoded.TimeZone + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azuresqlprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azuresqlprotectionpolicy.go new file mode 100644 index 00000000000..81c80d157da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azuresqlprotectionpolicy.go @@ -0,0 +1,70 @@ +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 + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureSqlProtectionPolicy{} + +func (s AzureSqlProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureSql" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureSqlProtectionPolicy{} + +func (s *AzureSqlProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureSqlProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureSqlProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureSqlProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go new file mode 100644 index 00000000000..0e318d65945 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go @@ -0,0 +1,46 @@ +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 + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadProtectionPolicy{} + +func (s AzureVMWorkloadProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureWorkload" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_dailyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_dailyretentionformat.go new file mode 100644 index 00000000000..1c5f0a22c9b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_dailyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_dailyretentionschedule.go new file mode 100644 index 00000000000..581a2b22ed5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_dailyschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_dailyschedule.go new file mode 100644 index 00000000000..34b307b9262 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_day.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_day.go new file mode 100644 index 00000000000..c46c7f57129 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_genericprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_genericprotectionpolicy.go new file mode 100644 index 00000000000..16227cb1edd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_genericprotectionpolicy.go @@ -0,0 +1,45 @@ +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 + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = GenericProtectionPolicy{} + +func (s GenericProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "GenericProtectionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_hourlyschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_hourlyschedule.go new file mode 100644 index 00000000000..f9f1a5a1d3c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_instantrpadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_instantrpadditionaldetails.go new file mode 100644 index 00000000000..f70f265dc45 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_logschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_logschedulepolicy.go new file mode 100644 index 00000000000..b4c2dd2d4f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_logschedulepolicy.go @@ -0,0 +1,41 @@ +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 +} + +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-02-01/backuppolicies/model_longtermretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_longtermretentionpolicy.go new file mode 100644 index 00000000000..4f27496b945 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_longtermretentionpolicy.go @@ -0,0 +1,44 @@ +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 +} + +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-02-01/backuppolicies/model_longtermschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_longtermschedulepolicy.go new file mode 100644 index 00000000000..00b2bec7ab3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_longtermschedulepolicy.go @@ -0,0 +1,40 @@ +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 +} + +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-02-01/backuppolicies/model_mabprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_mabprotectionpolicy.go new file mode 100644 index 00000000000..066b0138a5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_mabprotectionpolicy.go @@ -0,0 +1,79 @@ +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 + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = MabProtectionPolicy{} + +func (s MabProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper MabProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "MAB" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &MabProtectionPolicy{} + +func (s *MabProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias MabProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MabProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'MabProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'MabProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_monthlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_monthlyretentionschedule.go new file mode 100644 index 00000000000..8b8118cc9ee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_protectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_protectionpolicy.go new file mode 100644 index 00000000000..d3fdb550ef9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_protectionpolicy.go @@ -0,0 +1,93 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionPolicyImplementation(input []byte) (ProtectionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["backupManagementType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureStorage") { + var out AzureFileShareProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaasVM") { + var out AzureIaaSVMProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSql") { + var out AzureSqlProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkload") { + var out AzureVMWorkloadProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectionPolicy") { + var out GenericProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MAB") { + var out MabProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + return out, nil + } + + out := RawProtectionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_protectionpolicyresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_protectionpolicyresource.go new file mode 100644 index 00000000000..6af342ec8f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_protectionpolicyresource.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. + +type ProtectionPolicyResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionPolicy `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionPolicyResource{} + +func (s *ProtectionPolicyResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionPolicyResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionPolicyResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionPolicyResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionPolicyResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_retentionduration.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_retentionduration.go new file mode 100644 index 00000000000..60ecd1bea07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_retentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_retentionpolicy.go new file mode 100644 index 00000000000..515fe95872e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_retentionpolicy.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalRetentionPolicyImplementation(input []byte) (RetentionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RetentionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["retentionPolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LongTermRetentionPolicy") { + var out LongTermRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermRetentionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleRetentionPolicy") { + var out SimpleRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleRetentionPolicy: %+v", err) + } + return out, nil + } + + out := RawRetentionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_schedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_schedulepolicy.go new file mode 100644 index 00000000000..83aeb4b2344 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_schedulepolicy.go @@ -0,0 +1,77 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalSchedulePolicyImplementation(input []byte) (SchedulePolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SchedulePolicy into map[string]interface: %+v", err) + } + + value, ok := temp["schedulePolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LogSchedulePolicy") { + var out LogSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LogSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "LongTermSchedulePolicy") { + var out LongTermSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicy") { + var out SimpleSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicyV2") { + var out SimpleSchedulePolicyV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicyV2: %+v", err) + } + return out, nil + } + + out := RawSchedulePolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_settings.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_settings.go new file mode 100644 index 00000000000..c59cc13bdbe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_simpleretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleretentionpolicy.go new file mode 100644 index 00000000000..6355b65c8af --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleretentionpolicy.go @@ -0,0 +1,41 @@ +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 +} + +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-02-01/backuppolicies/model_simpleschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleschedulepolicy.go new file mode 100644 index 00000000000..cf047b354c2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleschedulepolicy.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/backuppolicies/model_simpleschedulepolicyv2.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleschedulepolicyv2.go new file mode 100644 index 00000000000..f8324d396c2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_simpleschedulepolicyv2.go @@ -0,0 +1,44 @@ +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 +} + +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-02-01/backuppolicies/model_snapshotbackupadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_snapshotbackupadditionaldetails.go new file mode 100644 index 00000000000..33761b836e4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_subprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_subprotectionpolicy.go new file mode 100644 index 00000000000..a60dd15ec41 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_subprotectionpolicy.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. + +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 { + type alias SubProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into SubProtectionPolicy: %+v", err) + } + + s.PolicyType = decoded.PolicyType + s.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-02-01/backuppolicies/model_tieringpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_tieringpolicy.go new file mode 100644 index 00000000000..6075f6ce494 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..7f80e2e49db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..562196aa29d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_vaultretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_vaultretentionpolicy.go new file mode 100644 index 00000000000..7520633b946 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_vaultretentionpolicy.go @@ -0,0 +1,40 @@ +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 { + type alias VaultRetentionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into VaultRetentionPolicy: %+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-02-01/backuppolicies/model_weeklyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_weeklyretentionformat.go new file mode 100644 index 00000000000..33dbf7e202c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_weeklyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_weeklyretentionschedule.go new file mode 100644 index 00000000000..edfa118dffc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_weeklyschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_weeklyschedule.go new file mode 100644 index 00000000000..93dcb41a53c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/model_yearlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/model_yearlyretentionschedule.go new file mode 100644 index 00000000000..f2c784a79d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/predicates.go new file mode 100644 index 00000000000..cdc446bbcfb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backuppolicies/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/version.go new file mode 100644 index 00000000000..c900b107e67 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies/version.go @@ -0,0 +1,12 @@ +package backuppolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backuppolicies/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/README.md new file mode 100644 index 00000000000..037a5cc922e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems` Documentation + +The `backupprotectableitems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-01/backupprotectableitems" +``` + + +### Client Initialization + +```go +client := backupprotectableitems.NewBackupProtectableItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectableItemsClient.List` + +```go +ctx := context.TODO() +id := backupprotectableitems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupprotectableitems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotectableitems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/client.go new file mode 100644 index 00000000000..a30b2396b90 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectableitems/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/constants.go new file mode 100644 index 00000000000..4707e9072d4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/constants.go @@ -0,0 +1,105 @@ +package backupprotectableitems + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileShareType string + +const ( + AzureFileShareTypeInvalid AzureFileShareType = "Invalid" + AzureFileShareTypeXSMB AzureFileShareType = "XSMB" + AzureFileShareTypeXSync AzureFileShareType = "XSync" +) + +func PossibleValuesForAzureFileShareType() []string { + return []string{ + string(AzureFileShareTypeInvalid), + string(AzureFileShareTypeXSMB), + string(AzureFileShareTypeXSync), + } +} + +func parseAzureFileShareType(input string) (*AzureFileShareType, error) { + vals := map[string]AzureFileShareType{ + "invalid": AzureFileShareTypeInvalid, + "xsmb": AzureFileShareTypeXSMB, + "xsync": AzureFileShareTypeXSync, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFileShareType(input) + return &out, nil +} + +type InquiryStatus string + +const ( + InquiryStatusFailed InquiryStatus = "Failed" + InquiryStatusInvalid InquiryStatus = "Invalid" + InquiryStatusSuccess InquiryStatus = "Success" +) + +func PossibleValuesForInquiryStatus() []string { + return []string{ + string(InquiryStatusFailed), + string(InquiryStatusInvalid), + string(InquiryStatusSuccess), + } +} + +func parseInquiryStatus(input string) (*InquiryStatus, error) { + vals := map[string]InquiryStatus{ + "failed": InquiryStatusFailed, + "invalid": InquiryStatusInvalid, + "success": InquiryStatusSuccess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InquiryStatus(input) + return &out, nil +} + +type ProtectionStatus string + +const ( + ProtectionStatusInvalid ProtectionStatus = "Invalid" + ProtectionStatusNotProtected ProtectionStatus = "NotProtected" + ProtectionStatusProtected ProtectionStatus = "Protected" + ProtectionStatusProtecting ProtectionStatus = "Protecting" + ProtectionStatusProtectionFailed ProtectionStatus = "ProtectionFailed" +) + +func PossibleValuesForProtectionStatus() []string { + return []string{ + string(ProtectionStatusInvalid), + string(ProtectionStatusNotProtected), + string(ProtectionStatusProtected), + string(ProtectionStatusProtecting), + string(ProtectionStatusProtectionFailed), + } +} + +func parseProtectionStatus(input string) (*ProtectionStatus, error) { + vals := map[string]ProtectionStatus{ + "invalid": ProtectionStatusInvalid, + "notprotected": ProtectionStatusNotProtected, + "protected": ProtectionStatusProtected, + "protecting": ProtectionStatusProtecting, + "protectionfailed": ProtectionStatusProtectionFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/id_vault.go new file mode 100644 index 00000000000..e80d10132d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/id_vault.go @@ -0,0 +1,125 @@ +package backupprotectableitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/id_vault_test.go new file mode 100644 index 00000000000..bd20ab17bf4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupprotectableitems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/method_list_autorest.go new file mode 100644 index 00000000000..7e33743e477 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectableitems/model_azurefileshareprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurefileshareprotectableitem.go new file mode 100644 index 00000000000..609db8fe641 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurefileshareprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureFileShareProtectableItem{} + +type AzureFileShareProtectableItem struct { + AzureFileShareType *AzureFileShareType `json:"azureFileShareType,omitempty"` + ParentContainerFabricId *string `json:"parentContainerFabricId,omitempty"` + ParentContainerFriendlyName *string `json:"parentContainerFriendlyName,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureFileShareProtectableItem{} + +func (s AzureFileShareProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "AzureFileShare" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go new file mode 100644 index 00000000000..14d4cde39da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureIaaSClassicComputeVMProtectableItem{} + +type AzureIaaSClassicComputeVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectableItem{} + +func (s AzureIaaSClassicComputeVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go new file mode 100644 index 00000000000..13c811a243b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureIaaSComputeVMProtectableItem{} + +type AzureIaaSComputeVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectableItem{} + +func (s AzureIaaSComputeVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go new file mode 100644 index 00000000000..09d4180bc8b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go @@ -0,0 +1,53 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadProtectableItem{} + +func (s AzureVMWorkloadProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "AzureVmWorkloadProtectableItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go new file mode 100644 index 00000000000..e8c296b457a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go @@ -0,0 +1,53 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseSystemProtectableItem{} + +func (s AzureVMWorkloadSAPAseSystemProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseSystemProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPAseSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go new file mode 100644 index 00000000000..cc7165679d2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go @@ -0,0 +1,53 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseProtectableItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go new file mode 100644 index 00000000000..0008fcf4e42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go @@ -0,0 +1,53 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go new file mode 100644 index 00000000000..77c1a0ac05f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go @@ -0,0 +1,53 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go new file mode 100644 index 00000000000..c190e0aab39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go @@ -0,0 +1,53 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaSystemProtectableItem{} + +func (s AzureVMWorkloadSAPHanaSystemProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaSystemProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPHanaSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go new file mode 100644 index 00000000000..9e5b0a12699 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go @@ -0,0 +1,54 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLAvailabilityGroupProtectableItem{} + +func (s AzureVMWorkloadSQLAvailabilityGroupProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLAvailabilityGroupProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLAvailabilityGroupContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go new file mode 100644 index 00000000000..87ce15895d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go @@ -0,0 +1,53 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseProtectableItem{} + +func (s AzureVMWorkloadSQLDatabaseProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLDataBase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go new file mode 100644 index 00000000000..f963bac71b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go @@ -0,0 +1,53 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLInstanceProtectableItem{} + +func (s AzureVMWorkloadSQLInstanceProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLInstanceProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_distributednodesinfo.go new file mode 100644 index 00000000000..6e96dfe461c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectableitems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_errordetail.go new file mode 100644 index 00000000000..1c3fd85652e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectableitems/model_iaasvmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_iaasvmprotectableitem.go new file mode 100644 index 00000000000..c05ab27225f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_iaasvmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = IaaSVMProtectableItem{} + +type IaaSVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = IaaSVMProtectableItem{} + +func (s IaaSVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "IaaSVMProtectableItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_prebackupvalidation.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_prebackupvalidation.go new file mode 100644 index 00000000000..955dd612808 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectableitems/model_workloadprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_workloadprotectableitem.go new file mode 100644 index 00000000000..91f978fc79b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_workloadprotectableitem.go @@ -0,0 +1,149 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalWorkloadProtectableItemImplementation(input []byte) (WorkloadProtectableItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling WorkloadProtectableItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectableItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShare") { + var out AzureFileShareProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectableItem") { + var out AzureVMWorkloadProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPAseSystem") { + var out AzureVMWorkloadSAPAseSystemProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "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 + } + + out := RawWorkloadProtectableItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_workloadprotectableitemresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_workloadprotectableitemresource.go new file mode 100644 index 00000000000..3f03589ca2d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/model_workloadprotectableitemresource.go @@ -0,0 +1,50 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProtectableItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkloadProtectableItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &WorkloadProtectableItemResource{} + +func (s *WorkloadProtectableItemResource) UnmarshalJSON(bytes []byte) error { + type alias WorkloadProtectableItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into WorkloadProtectableItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling WorkloadProtectableItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalWorkloadProtectableItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'WorkloadProtectableItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/predicates.go new file mode 100644 index 00000000000..464f22ae33b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectableitems/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/version.go new file mode 100644 index 00000000000..5f788e842bb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems/version.go @@ -0,0 +1,12 @@ +package backupprotectableitems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotectableitems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/README.md new file mode 100644 index 00000000000..5ed39305873 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems` Documentation + +The `backupprotecteditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-01/backupprotecteditems" +``` + + +### Client Initialization + +```go +client := backupprotecteditems.NewBackupProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectedItemsClient.List` + +```go +ctx := context.TODO() +id := backupprotecteditems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupprotecteditems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotecteditems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/client.go new file mode 100644 index 00000000000..7bb37dd5d36 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/constants.go new file mode 100644 index 00000000000..a0cadc76937 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/constants.go @@ -0,0 +1,387 @@ +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-02-01/backupprotecteditems/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/id_vault.go new file mode 100644 index 00000000000..0a96fa52459 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/id_vault.go @@ -0,0 +1,125 @@ +package backupprotecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/id_vault_test.go new file mode 100644 index 00000000000..605452dfc17 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupprotecteditems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/method_list_autorest.go new file mode 100644 index 00000000000..5b5c8cd79c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_azurefileshareprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurefileshareprotecteditem.go new file mode 100644 index 00000000000..c3298a1bd0c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurefileshareprotecteditem.go @@ -0,0 +1,92 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureFileshareProtectedItem{} + +type AzureFileshareProtectedItem struct { + ExtendedInfo *AzureFileshareProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureFileshareProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureFileshareProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureFileshareProtectedItem{} + +func (s AzureFileshareProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileshareProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileshareProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileshareProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureFileShareProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileshareProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go new file mode 100644 index 00000000000..784dbda1d5d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go new file mode 100644 index 00000000000..02fc57f6284 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go @@ -0,0 +1,97 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSClassicComputeVMProtectedItem{} + +type AzureIaaSClassicComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectedItem{} + +func (s AzureIaaSClassicComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go new file mode 100644 index 00000000000..cd68214dabe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go @@ -0,0 +1,97 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSComputeVMProtectedItem{} + +type AzureIaaSComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectedItem{} + +func (s AzureIaaSComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasvmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasvmprotecteditem.go new file mode 100644 index 00000000000..1af736c9ff1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasvmprotecteditem.go @@ -0,0 +1,97 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSVMProtectedItem{} + +type AzureIaaSVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSVMProtectedItem{} + +func (s AzureIaaSVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureIaaSVMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..f9bd89ad856 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_azuresqlprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azuresqlprotecteditem.go new file mode 100644 index 00000000000..57afd68710c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azuresqlprotecteditem.go @@ -0,0 +1,88 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureSqlProtectedItem{} + +type AzureSqlProtectedItem struct { + ExtendedInfo *AzureSqlProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureSqlProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureSqlProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureSqlProtectedItem{} + +func (s AzureSqlProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Sql/servers/databases" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go new file mode 100644 index 00000000000..1f95cebc98c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go new file mode 100644 index 00000000000..3a61cfb08ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go new file mode 100644 index 00000000000..4ad1e158847 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go new file mode 100644 index 00000000000..1f562982e49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go new file mode 100644 index 00000000000..f5ad71c3f66 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go new file mode 100644 index 00000000000..a26f205aef2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go new file mode 100644 index 00000000000..df776fba105 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/backupprotecteditems/model_diskexclusionproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_diskexclusionproperties.go new file mode 100644 index 00000000000..f12fc0030e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_distributednodesinfo.go new file mode 100644 index 00000000000..739b4bcf82a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_dpmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_dpmprotecteditem.go new file mode 100644 index 00000000000..e17a5b340fc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_dpmprotecteditem.go @@ -0,0 +1,89 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = DPMProtectedItem{} + +type DPMProtectedItem struct { + BackupEngineName *string `json:"backupEngineName,omitempty"` + ExtendedInfo *DPMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *DPMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *DPMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = DPMProtectedItem{} + +func (s DPMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper DPMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DPMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DPMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "DPMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DPMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..c28c138b06e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_errordetail.go new file mode 100644 index 00000000000..c55cc388bf9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_extendedproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_extendedproperties.go new file mode 100644 index 00000000000..bd52e28b60e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_genericprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_genericprotecteditem.go new file mode 100644 index 00000000000..98ab0962040 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_genericprotecteditem.go @@ -0,0 +1,91 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = GenericProtectedItem{} + +type GenericProtectedItem struct { + FabricName *string `json:"fabricName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + ProtectedItemId *int64 `json:"protectedItemId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + SourceAssociations *map[string]string `json:"sourceAssociations,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *GenericProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *GenericProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = GenericProtectedItem{} + +func (s GenericProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "GenericProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_kpiresourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_kpiresourcehealthdetails.go new file mode 100644 index 00000000000..42a11e535b9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_mabfilefolderprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_mabfilefolderprotecteditem.go new file mode 100644 index 00000000000..800796cc649 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_mabfilefolderprotecteditem.go @@ -0,0 +1,92 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = MabFileFolderProtectedItem{} + +type MabFileFolderProtectedItem struct { + ComputerName *string `json:"computerName,omitempty"` + DeferredDeleteSyncTimeInUTC *int64 `json:"deferredDeleteSyncTimeInUTC,omitempty"` + ExtendedInfo *MabFileFolderProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *MabFileFolderProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *MabFileFolderProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = MabFileFolderProtectedItem{} + +func (s MabFileFolderProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper MabFileFolderProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabFileFolderProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabFileFolderProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "MabFileFolderProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabFileFolderProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go new file mode 100644 index 00000000000..30f88b5c2ac --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/model_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_protecteditem.go new file mode 100644 index 00000000000..c0293f0a808 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_protecteditem.go @@ -0,0 +1,149 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalProtectedItemImplementation(input []byte) (ProtectedItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectedItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectedItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareProtectedItem") { + var out AzureFileshareProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileshareProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMProtectedItem") { + var out AzureIaaSVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Sql/servers/databases") { + var out AzureSqlProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectedItem") { + var out AzureVMWorkloadProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPAseDatabase") { + var out AzureVMWorkloadSAPAseDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "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 + } + + out := RawProtectedItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_protecteditemresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_protecteditemresource.go new file mode 100644 index 00000000000..cf1da7db76f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_protecteditemresource.go @@ -0,0 +1,50 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectedItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectedItemResource{} + +func (s *ProtectedItemResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectedItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectedItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectedItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectedItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectedItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_resourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/model_resourcehealthdetails.go new file mode 100644 index 00000000000..34cb35fbf15 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/predicates.go new file mode 100644 index 00000000000..92b0067d35e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotecteditems/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/version.go new file mode 100644 index 00000000000..6f1bc5332e9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems/version.go @@ -0,0 +1,12 @@ +package backupprotecteditems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotecteditems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/README.md new file mode 100644 index 00000000000..5cf6747bffb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers` Documentation + +The `backupprotectioncontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +// 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-02-01/backupprotectioncontainers/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/client.go new file mode 100644 index 00000000000..80d302c783e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/constants.go new file mode 100644 index 00000000000..80a7af4df07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/constants.go @@ -0,0 +1,330 @@ +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-02-01/backupprotectioncontainers/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/id_vault.go new file mode 100644 index 00000000000..b64d7868eec --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/id_vault.go @@ -0,0 +1,125 @@ +package backupprotectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/id_vault_test.go new file mode 100644 index 00000000000..bb4ab374fbf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupprotectioncontainers/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/method_list_autorest.go new file mode 100644 index 00000000000..2395d76d2f4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..491a5d88bc7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurebackupservercontainer.go @@ -0,0 +1,53 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureBackupServerContainer{} + +func (s AzureBackupServerContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerContainer: %+v", err) + } + decoded["containerType"] = "AzureBackupServerContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..65ce2a73e0e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,48 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMContainer{} + +func (s AzureIaaSClassicComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..2cc11651a91 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,48 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMContainer{} + +func (s AzureIaaSComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..0c3557434a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSQLAGWorkloadContainerProtectionContainer{} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSQLAGWorkloadContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "SQLAGWorkLoadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..6a6ebd42209 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azuresqlcontainer.go @@ -0,0 +1,45 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSqlContainer{} + +func (s AzureSqlContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlContainer: %+v", err) + } + decoded["containerType"] = "AzureSqlContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..2517538ab11 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurestoragecontainer.go @@ -0,0 +1,50 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureStorageContainer{} + +func (s AzureStorageContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageContainer: %+v", err) + } + decoded["containerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..791890dda6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureVMAppContainerProtectionContainer{} + +func (s AzureVMAppContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..4bd85bb2f86 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureworkloadcontainer.go @@ -0,0 +1,50 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainer{} + +func (s AzureWorkloadContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainer: %+v", err) + } + decoded["containerType"] = "AzureWorkloadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..4e6205329b2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..8cff0e16315 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..88d6fe5dcf8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..d8f981a383a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_dpmcontainer.go @@ -0,0 +1,53 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = DpmContainer{} + +func (s DpmContainer) MarshalJSON() ([]byte, error) { + type wrapper DpmContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmContainer: %+v", err) + } + decoded["containerType"] = "DPMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..62c9b305962 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_errordetail.go new file mode 100644 index 00000000000..86008b3edcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_genericcontainer.go new file mode 100644 index 00000000000..1b4450ed88f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_genericcontainer.go @@ -0,0 +1,47 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = GenericContainer{} + +func (s GenericContainer) MarshalJSON() ([]byte, error) { + type wrapper GenericContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericContainer: %+v", err) + } + decoded["containerType"] = "GenericContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..82f18cd823f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..442fd35fe13 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_iaasvmcontainer.go @@ -0,0 +1,48 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = IaaSVMContainer{} + +func (s IaaSVMContainer) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMContainer: %+v", err) + } + decoded["containerType"] = "IaasVMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..93ec19a6ba0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..f33ed3584b2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_mabcontainer.go new file mode 100644 index 00000000000..d9cd5599d7e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_mabcontainer.go @@ -0,0 +1,52 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = MabContainer{} + +func (s MabContainer) MarshalJSON() ([]byte, error) { + type wrapper MabContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabContainer: %+v", err) + } + decoded["containerType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..b23e3796a39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..7c04be9060e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..a675bf0357d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_protectioncontainer.go @@ -0,0 +1,141 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionContainerImplementation(input []byte) (ProtectionContainer, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionContainer into map[string]interface: %+v", err) + } + + value, ok := temp["containerType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupServerContainer") { + var out AzureBackupServerContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAGWorkLoadContainer") { + var out AzureSQLAGWorkloadContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSqlContainer") { + var out AzureSqlContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainer") { + var out AzureWorkloadContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMContainer") { + var out DpmContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericContainer") { + var out GenericContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMContainer") { + var out IaaSVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out MabContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabContainer: %+v", err) + } + return out, nil + } + + out := RawProtectionContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..c112fdde08b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_protectioncontainerresource.go @@ -0,0 +1,50 @@ +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 { + type alias ProtectionContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionContainerResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionContainerResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..fd796f17a93 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/predicates.go new file mode 100644 index 00000000000..2c7170b0702 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectioncontainers/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/version.go new file mode 100644 index 00000000000..a2f2336359b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers/version.go @@ -0,0 +1,12 @@ +package backupprotectioncontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotectioncontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/README.md new file mode 100644 index 00000000000..64f612f5b00 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent` Documentation + +The `backupprotectionintent` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +// 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-02-01/backupprotectionintent/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/client.go new file mode 100644 index 00000000000..10dc6db01e1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectionintent/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/constants.go new file mode 100644 index 00000000000..3329c4a8723 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/constants.go @@ -0,0 +1,178 @@ +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-02-01/backupprotectionintent/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/id_vault.go new file mode 100644 index 00000000000..34115c2868e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/id_vault.go @@ -0,0 +1,125 @@ +package backupprotectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/id_vault_test.go new file mode 100644 index 00000000000..a898fa26800 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupprotectionintent/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/method_list_autorest.go new file mode 100644 index 00000000000..9e4e60e7b48 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go new file mode 100644 index 00000000000..b977432cd8e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go @@ -0,0 +1,45 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/backupprotectionintent/model_azureresourceprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureresourceprotectionintent.go new file mode 100644 index 00000000000..4583889073c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureresourceprotectionintent.go @@ -0,0 +1,46 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go new file mode 100644 index 00000000000..267e3b491a5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go @@ -0,0 +1,45 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go new file mode 100644 index 00000000000..a8769e454d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go @@ -0,0 +1,45 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go new file mode 100644 index 00000000000..f08a42d327c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go @@ -0,0 +1,46 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/backupprotectionintent/model_protectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_protectionintent.go new file mode 100644 index 00000000000..37d03a79726 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_protectionintent.go @@ -0,0 +1,85 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["protectionIntentItemType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawProtectionIntentImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_protectionintentresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_protectionintentresource.go new file mode 100644 index 00000000000..08b6ed4abda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/model_protectionintentresource.go @@ -0,0 +1,50 @@ +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 { + type alias ProtectionIntentResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionIntentResource: %+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-02-01/backupprotectionintent/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/predicates.go new file mode 100644 index 00000000000..26161b72fe6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupprotectionintent/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/version.go new file mode 100644 index 00000000000..172e11eddce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent/version.go @@ -0,0 +1,12 @@ +package backupprotectionintent + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotectionintent/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/README.md new file mode 100644 index 00000000000..578f8270d10 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/README.md @@ -0,0 +1,57 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs` Documentation + +The `backupresourceencryptionconfigs` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +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", "vaultValue") + +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-02-01/backupresourceencryptionconfigs/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/client.go new file mode 100644 index 00000000000..5b406d30285 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourceencryptionconfigs/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/constants.go new file mode 100644 index 00000000000..0c18f2887db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/constants.go @@ -0,0 +1,114 @@ +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-02-01/backupresourceencryptionconfigs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/id_vault.go new file mode 100644 index 00000000000..e2725544a68 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/id_vault.go @@ -0,0 +1,125 @@ +package backupresourceencryptionconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/id_vault_test.go new file mode 100644 index 00000000000..94221b356e4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupresourceencryptionconfigs/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/method_get_autorest.go new file mode 100644 index 00000000000..8946fde875a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourceencryptionconfigs/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/method_update_autorest.go new file mode 100644 index 00000000000..8e72a546ee0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go new file mode 100644 index 00000000000..04c2d9832cb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go new file mode 100644 index 00000000000..c58a1406581 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go new file mode 100644 index 00000000000..748ecae7a86 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go new file mode 100644 index 00000000000..2bdfb74ffb3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourceencryptionconfigs/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/version.go new file mode 100644 index 00000000000..54eef04bab7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs/version.go @@ -0,0 +1,12 @@ +package backupresourceencryptionconfigs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupresourceencryptionconfigs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/README.md new file mode 100644 index 00000000000..c4e8429ed58 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/README.md @@ -0,0 +1,78 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr` Documentation + +The `backupresourcestorageconfigsnoncrr` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +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", "vaultValue") + +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", "vaultValue") + +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-02-01/backupresourcestorageconfigsnoncrr/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/client.go new file mode 100644 index 00000000000..88d28c49c49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcestorageconfigsnoncrr/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/constants.go new file mode 100644 index 00000000000..6ae51ba9c4a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/constants.go @@ -0,0 +1,136 @@ +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-02-01/backupresourcestorageconfigsnoncrr/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/id_vault.go new file mode 100644 index 00000000000..73028f742d0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/id_vault.go @@ -0,0 +1,125 @@ +package backupresourcestorageconfigsnoncrr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/id_vault_test.go new file mode 100644 index 00000000000..1be676b3d31 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go new file mode 100644 index 00000000000..dfa7631d81e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go new file mode 100644 index 00000000000..06e35a3cb44 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go new file mode 100644 index 00000000000..13a010ee69d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go new file mode 100644 index 00000000000..69f226c0dcf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go new file mode 100644 index 00000000000..8fc2680cafb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcestorageconfigsnoncrr/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/version.go new file mode 100644 index 00000000000..5b1cd77a3a4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr/version.go @@ -0,0 +1,12 @@ +package backupresourcestorageconfigsnoncrr + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupresourcestorageconfigsnoncrr/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/README.md new file mode 100644 index 00000000000..2f0807adf8c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/README.md @@ -0,0 +1,78 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs` Documentation + +The `backupresourcevaultconfigs` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +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", "vaultValue") + +payload := backupresourcevaultconfigs.BackupResourceVaultConfigResource{ + // ... +} + + +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: `BackupResourceVaultConfigsClient.Update` + +```go +ctx := context.TODO() +id := backupresourcevaultconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := backupresourcevaultconfigs.BackupResourceVaultConfigResource{ + // ... +} + + +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-02-01/backupresourcevaultconfigs/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/client.go new file mode 100644 index 00000000000..b56d05bcc6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcevaultconfigs/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/constants.go new file mode 100644 index 00000000000..3be392d6155 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/constants.go @@ -0,0 +1,139 @@ +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-02-01/backupresourcevaultconfigs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/id_vault.go new file mode 100644 index 00000000000..27a4a75f881 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/id_vault.go @@ -0,0 +1,125 @@ +package backupresourcevaultconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/id_vault_test.go new file mode 100644 index 00000000000..4fc8cf8e4f0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupresourcevaultconfigs/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/method_get_autorest.go new file mode 100644 index 00000000000..709a6190da7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcevaultconfigs/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/method_put_autorest.go new file mode 100644 index 00000000000..d7874fa3e4f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/method_put_autorest.go @@ -0,0 +1,70 @@ +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 +} + +// Put ... +func (c BackupResourceVaultConfigsClient) Put(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource) (result PutOperationResponse, err error) { + req, err := c.preparerForPut(ctx, id, input) + 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) (*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/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-02-01/backupresourcevaultconfigs/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/method_update_autorest.go new file mode 100644 index 00000000000..834657e3477 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/method_update_autorest.go @@ -0,0 +1,70 @@ +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 +} + +// Update ... +func (c BackupResourceVaultConfigsClient) Update(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + 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) (*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/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-02-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go new file mode 100644 index 00000000000..43c59de4141 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go new file mode 100644 index 00000000000..9957131bbd6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupresourcevaultconfigs/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/version.go new file mode 100644 index 00000000000..e27b047a964 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs/version.go @@ -0,0 +1,12 @@ +package backupresourcevaultconfigs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupresourcevaultconfigs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backups/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backups/README.md new file mode 100644 index 00000000000..f2380343435 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backups` Documentation + +The `backups` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +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-02-01/backups/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/client.go new file mode 100644 index 00000000000..8669bac74ee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backups/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/constants.go new file mode 100644 index 00000000000..28cae0d72b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/constants.go @@ -0,0 +1,52 @@ +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-02-01/backups/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/id_protecteditem.go new file mode 100644 index 00000000000..6167c5ae497 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/id_protecteditem.go @@ -0,0 +1,152 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backups/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/id_protecteditem_test.go new file mode 100644 index 00000000000..e724aa39827 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/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-02-01/backups/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/method_trigger_autorest.go new file mode 100644 index 00000000000..bf23ac4685b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backups/model_azurefilesharebackuprequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_azurefilesharebackuprequest.go new file mode 100644 index 00000000000..99ddceed9c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_azurefilesharebackuprequest.go @@ -0,0 +1,41 @@ +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 +} + +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-02-01/backups/model_azureworkloadbackuprequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_azureworkloadbackuprequest.go new file mode 100644 index 00000000000..dff561d8271 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_azureworkloadbackuprequest.go @@ -0,0 +1,43 @@ +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 +} + +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-02-01/backups/model_backuprequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_backuprequest.go new file mode 100644 index 00000000000..2f905da3c3c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_backuprequest.go @@ -0,0 +1,69 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawBackupRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_backuprequestresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_backuprequestresource.go new file mode 100644 index 00000000000..9f57a8a255b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_backuprequestresource.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. + +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 { + type alias BackupRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into BackupRequestResource: %+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-02-01/backups/model_iaasvmbackuprequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_iaasvmbackuprequest.go new file mode 100644 index 00000000000..d40c0c3ccf0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/model_iaasvmbackuprequest.go @@ -0,0 +1,41 @@ +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 +} + +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-02-01/backups/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backups/version.go new file mode 100644 index 00000000000..d270c2059d0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backups/version.go @@ -0,0 +1,12 @@ +package backups + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backups/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/README.md new file mode 100644 index 00000000000..c49318240ff --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus` Documentation + +The `backupstatus` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "locationValue") + +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-02-01/backupstatus/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/client.go new file mode 100644 index 00000000000..d17f64f2d24 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupstatus/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/constants.go new file mode 100644 index 00000000000..aa16bf7cbcf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/constants.go @@ -0,0 +1,169 @@ +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-02-01/backupstatus/id_location.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/id_location.go new file mode 100644 index 00000000000..c7bfa39467e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/id_location.go @@ -0,0 +1,116 @@ +package backupstatus + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "locationValue"), + } +} + +// 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-02-01/backupstatus/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/id_location_test.go new file mode 100644 index 00000000000..83bf34ce9e5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "locationValue") + + 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 != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue" + 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/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/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/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe/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-02-01/backupstatus/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/method_get_autorest.go new file mode 100644 index 00000000000..5bdbd049ea0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupstatus/model_backupstatusrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/model_backupstatusrequest.go new file mode 100644 index 00000000000..18355d1d1a4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupstatus/model_backupstatusresponse.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/model_backupstatusresponse.go new file mode 100644 index 00000000000..18836147a5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupstatus/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/version.go new file mode 100644 index 00000000000..a3f6a11833a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus/version.go @@ -0,0 +1,12 @@ +package backupstatus + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupstatus/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/README.md new file mode 100644 index 00000000000..ac808a5db17 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries` Documentation + +The `backupusagesummaries` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +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-02-01/backupusagesummaries/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/client.go new file mode 100644 index 00000000000..d6dbffa806e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupusagesummaries/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/constants.go new file mode 100644 index 00000000000..397d5b32331 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/constants.go @@ -0,0 +1,46 @@ +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-02-01/backupusagesummaries/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/id_vault.go new file mode 100644 index 00000000000..4c2673bec42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/id_vault.go @@ -0,0 +1,125 @@ +package backupusagesummaries + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/id_vault_test.go new file mode 100644 index 00000000000..d76a76435c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/backupusagesummaries/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/method_list_autorest.go new file mode 100644 index 00000000000..f3562412897 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupusagesummaries/model_backupmanagementusage.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/model_backupmanagementusage.go new file mode 100644 index 00000000000..decb29b6951 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupusagesummaries/model_backupmanagementusagelist.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/model_backupmanagementusagelist.go new file mode 100644 index 00000000000..e2014e84694 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupusagesummaries/model_nameinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/model_nameinfo.go new file mode 100644 index 00000000000..68fde56d864 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupusagesummaries/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/version.go new file mode 100644 index 00000000000..bd20e1ba212 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries/version.go @@ -0,0 +1,12 @@ +package backupusagesummaries + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupusagesummaries/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/README.md new file mode 100644 index 00000000000..06d62ae7ddd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems` Documentation + +The `backupworkloaditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue") + +// 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-02-01/backupworkloaditems/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/client.go new file mode 100644 index 00000000000..2493a9d3ce5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupworkloaditems/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/constants.go new file mode 100644 index 00000000000..53f53e17687 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/constants.go @@ -0,0 +1,74 @@ +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-02-01/backupworkloaditems/id_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/id_protectioncontainer.go new file mode 100644 index 00000000000..1ca022191d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/id_protectioncontainer.go @@ -0,0 +1,143 @@ +package backupworkloaditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectionContainerId{} + +// ProtectionContainerId is a struct representing the Resource ID for a Protection Container +type ProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string +} + +// NewProtectionContainerID returns a new ProtectionContainerId struct +func NewProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string) ProtectionContainerId { + return ProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + } +} + +// ParseProtectionContainerID parses 'input' into a ProtectionContainerId +func ParseProtectionContainerID(input string) (*ProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + } +} + +// String returns a human-readable description of this Protection Container ID +func (id ProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + } + return fmt.Sprintf("Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/id_protectioncontainer_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/id_protectioncontainer_test.go new file mode 100644 index 00000000000..eba02653ce8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } +} + +func TestFormatProtectionContainerID(t *testing.T) { + actual := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/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-02-01/backupworkloaditems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/method_list_autorest.go new file mode 100644 index 00000000000..a730a74a266 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupworkloaditems/model_azurevmworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloaditem.go new file mode 100644 index 00000000000..69068df164a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloaditem.go @@ -0,0 +1,49 @@ +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"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go new file mode 100644 index 00000000000..d2b7b5b550a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go @@ -0,0 +1,49 @@ +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"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go new file mode 100644 index 00000000000..1f00dd9c164 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go @@ -0,0 +1,49 @@ +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"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go new file mode 100644 index 00000000000..49058e10e85 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go @@ -0,0 +1,49 @@ +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"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go new file mode 100644 index 00000000000..9b7e843c0bd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go @@ -0,0 +1,49 @@ +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"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go new file mode 100644 index 00000000000..d857da81c38 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go @@ -0,0 +1,49 @@ +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"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go new file mode 100644 index 00000000000..1179d25dea3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go @@ -0,0 +1,50 @@ +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"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +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-02-01/backupworkloaditems/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_sqldatadirectory.go new file mode 100644 index 00000000000..2bae2b886be --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupworkloaditems/model_workloaditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_workloaditem.go new file mode 100644 index 00000000000..83019e354ef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_workloaditem.go @@ -0,0 +1,101 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["workloadItemType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawWorkloadItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_workloaditemresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_workloaditemresource.go new file mode 100644 index 00000000000..2c4a15f25c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/model_workloaditemresource.go @@ -0,0 +1,50 @@ +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 { + type alias WorkloadItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into WorkloadItemResource: %+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-02-01/backupworkloaditems/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/predicates.go new file mode 100644 index 00000000000..98e6f2ee1de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/backupworkloaditems/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/version.go new file mode 100644 index 00000000000..3214f0d10b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems/version.go @@ -0,0 +1,12 @@ +package backupworkloaditems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupworkloaditems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/client.go new file mode 100644 index 00000000000..5f60f8e5c59 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/client.go @@ -0,0 +1,239 @@ +package v2024_02_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-02-01/backupengines" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupjobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backuppolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectableitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupprotecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupprotectionintent" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupresourceencryptionconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcestorageconfigsnoncrr" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupresourcevaultconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backups" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupstatus" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupusagesummaries" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/backupworkloaditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/datamove" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/jobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/operation" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/restores" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/securitypins" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-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-02-01/datamove/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/README.md new file mode 100644 index 00000000000..93068ff97d3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/datamove` Documentation + +The `datamove` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +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", "vaultValue") + +payload := datamove.TriggerDataMoveRequest{ + // ... +} + + +if err := client.BMSTriggerDataMoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/datamove/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/client.go new file mode 100644 index 00000000000..bca13a32cd6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/datamove/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/constants.go new file mode 100644 index 00000000000..86a3e471eea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/constants.go @@ -0,0 +1,37 @@ +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-02-01/datamove/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/id_vault.go new file mode 100644 index 00000000000..e2240d8c8b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/id_vault.go @@ -0,0 +1,125 @@ +package datamove + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/datamove/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/id_vault_test.go new file mode 100644 index 00000000000..8f4c2dcb1ae --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/datamove/method_bmspreparedatamove_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/method_bmspreparedatamove_autorest.go new file mode 100644 index 00000000000..460642bf637 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/datamove/method_bmstriggerdatamove_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/method_bmstriggerdatamove_autorest.go new file mode 100644 index 00000000000..5f89d916019 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/datamove/model_preparedatamoverequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/model_preparedatamoverequest.go new file mode 100644 index 00000000000..f2e39d1cd8a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/datamove/model_triggerdatamoverequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/model_triggerdatamoverequest.go new file mode 100644 index 00000000000..eb35ce70218 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/datamove/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/version.go new file mode 100644 index 00000000000..549b60026dd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/datamove/version.go @@ -0,0 +1,12 @@ +package datamove + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/datamove/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/README.md new file mode 100644 index 00000000000..8cf3cd4db4c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport` Documentation + +The `featuresupport` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "locationValue") + +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-02-01/featuresupport/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/client.go new file mode 100644 index 00000000000..b4f22ceed18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/featuresupport/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/constants.go new file mode 100644 index 00000000000..e44ccfc6c48 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/constants.go @@ -0,0 +1,43 @@ +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-02-01/featuresupport/id_location.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/id_location.go new file mode 100644 index 00000000000..452559d5a9e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/id_location.go @@ -0,0 +1,116 @@ +package featuresupport + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "locationValue"), + } +} + +// 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-02-01/featuresupport/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/id_location_test.go new file mode 100644 index 00000000000..e08a74f19c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "locationValue") + + 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 != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue" + 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/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/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/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe/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-02-01/featuresupport/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/method_validate_autorest.go new file mode 100644 index 00000000000..71e04fc843f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go new file mode 100644 index 00000000000..3d2bf051bd9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go @@ -0,0 +1,40 @@ +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 +} + +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-02-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go new file mode 100644 index 00000000000..b9e212a5b30 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go @@ -0,0 +1,42 @@ +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 +} + +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-02-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go new file mode 100644 index 00000000000..b9d8a42e54a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/featuresupport/model_featuresupportrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_featuresupportrequest.go new file mode 100644 index 00000000000..470e2a01527 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/model_featuresupportrequest.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["featureType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawFeatureSupportRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/version.go new file mode 100644 index 00000000000..0726626a1d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/featuresupport/version.go @@ -0,0 +1,12 @@ +package featuresupport + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/featuresupport/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/README.md new file mode 100644 index 00000000000..3f13b0c1fbc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost` Documentation + +The `fetchtieringcost` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +payload := fetchtieringcost.FetchTieringCostInfoRequest{ + // ... +} + + +if err := client.PostThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/client.go new file mode 100644 index 00000000000..c3df44f183a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/fetchtieringcost/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/constants.go new file mode 100644 index 00000000000..30e1f04df9f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/constants.go @@ -0,0 +1,68 @@ +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-02-01/fetchtieringcost/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/id_vault.go new file mode 100644 index 00000000000..601c84badf5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/id_vault.go @@ -0,0 +1,125 @@ +package fetchtieringcost + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/id_vault_test.go new file mode 100644 index 00000000000..8650d901df2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/fetchtieringcost/method_post_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/method_post_autorest.go new file mode 100644 index 00000000000..388a3bbc273 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go new file mode 100644 index 00000000000..4949da0922b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go @@ -0,0 +1,46 @@ +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 + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"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-02-01/fetchtieringcost/model_fetchtieringcostinforequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostinforequest.go new file mode 100644 index 00000000000..610799f0f84 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostinforequest.go @@ -0,0 +1,77 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawFetchTieringCostInfoRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go new file mode 100644 index 00000000000..a3ef8489a2c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go @@ -0,0 +1,43 @@ +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 + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"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-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go new file mode 100644 index 00000000000..6836ba25244 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go @@ -0,0 +1,44 @@ +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 + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"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-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go new file mode 100644 index 00000000000..bfa92fffc4e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go @@ -0,0 +1,42 @@ +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 + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"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-02-01/fetchtieringcost/model_tieringcostinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostinfo.go new file mode 100644 index 00000000000..3278ffb8d57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostinfo.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawTieringCostInfoImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostrehydrationinfo.go new file mode 100644 index 00000000000..7d3e00aafee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostrehydrationinfo.go @@ -0,0 +1,42 @@ +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 +} + +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-02-01/fetchtieringcost/model_tieringcostsavinginfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostsavinginfo.go new file mode 100644 index 00000000000..45dd137725c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/model_tieringcostsavinginfo.go @@ -0,0 +1,44 @@ +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 +} + +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-02-01/fetchtieringcost/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/version.go new file mode 100644 index 00000000000..cfb4c493669 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/fetchtieringcost/version.go @@ -0,0 +1,12 @@ +package fetchtieringcost + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/fetchtieringcost/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/README.md new file mode 100644 index 00000000000..57b287aa067 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/README.md @@ -0,0 +1,57 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections` Documentation + +The `itemlevelrecoveryconnections` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +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-02-01/itemlevelrecoveryconnections/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/client.go new file mode 100644 index 00000000000..9dc4e42e08b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/itemlevelrecoveryconnections/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/id_recoverypoint.go new file mode 100644 index 00000000000..56263cc7690 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/id_recoverypoint.go @@ -0,0 +1,161 @@ +package itemlevelrecoveryconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// 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-02-01/itemlevelrecoveryconnections/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/id_recoverypoint_test.go new file mode 100644 index 00000000000..0b3f033efd0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/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-02-01/itemlevelrecoveryconnections/method_provision_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/method_provision_autorest.go new file mode 100644 index 00000000000..9d96e89f2fd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/itemlevelrecoveryconnections/method_revoke_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/method_revoke_autorest.go new file mode 100644 index 00000000000..9ea351e638d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go new file mode 100644 index 00000000000..d93f105af7a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go @@ -0,0 +1,42 @@ +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 +} + +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-02-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go new file mode 100644 index 00000000000..87056a3101b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go @@ -0,0 +1,44 @@ +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 +} + +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-02-01/itemlevelrecoveryconnections/model_ilrrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_ilrrequest.go new file mode 100644 index 00000000000..06d898b4cc2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_ilrrequest.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawILRRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_ilrrequestresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_ilrrequestresource.go new file mode 100644 index 00000000000..b9b0865a658 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/model_ilrrequestresource.go @@ -0,0 +1,50 @@ +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 { + type alias ILRRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ILRRequestResource: %+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-02-01/itemlevelrecoveryconnections/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/version.go new file mode 100644 index 00000000000..68fbda13032 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/itemlevelrecoveryconnections/version.go @@ -0,0 +1,12 @@ +package itemlevelrecoveryconnections + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/itemlevelrecoveryconnections/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/client.go new file mode 100644 index 00000000000..00a3fc2ea01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobcancellations/id_backupjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/id_backupjob.go new file mode 100644 index 00000000000..954d9e48b0b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/id_backupjob.go @@ -0,0 +1,134 @@ +package jobcancellations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupJobs", "backupJobs", "backupJobs"), + resourceids.UserSpecifiedSegment("backupJobName", "backupJobValue"), + } +} + +// 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-02-01/jobcancellations/id_backupjob_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/id_backupjob_test.go new file mode 100644 index 00000000000..7c2473b8305 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupJobValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupJobName != "backupJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupJobName'", id.BackupJobName, "backupJobValue") + } +} + +func TestFormatBackupJobID(t *testing.T) { + actual := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupJobName: "backupJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupJobName: "backupJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue/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/vAuLtVaLuE/bAcKuPjObS/bAcKuPjObVaLuE", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupJobName: "bAcKuPjObVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPjObS/bAcKuPjObVaLuE/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-02-01/jobcancellations/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/method_trigger_autorest.go new file mode 100644 index 00000000000..9159d1476cb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobcancellations/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/version.go new file mode 100644 index 00000000000..ceda2df09ff --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobcancellations/version.go @@ -0,0 +1,12 @@ +package jobcancellations + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/jobcancellations/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/README.md new file mode 100644 index 00000000000..86b16604ad1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails` Documentation + +The `jobdetails` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupJobValue") + +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-02-01/jobdetails/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/client.go new file mode 100644 index 00000000000..465d9e82eba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/constants.go new file mode 100644 index 00000000000..a94046a0140 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/constants.go @@ -0,0 +1,223 @@ +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-02-01/jobdetails/id_backupjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/id_backupjob.go new file mode 100644 index 00000000000..c8589442b79 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/id_backupjob.go @@ -0,0 +1,134 @@ +package jobdetails + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupJobs", "backupJobs", "backupJobs"), + resourceids.UserSpecifiedSegment("backupJobName", "backupJobValue"), + } +} + +// 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-02-01/jobdetails/id_backupjob_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/id_backupjob_test.go new file mode 100644 index 00000000000..23a0fa12076 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupJobValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupJobName != "backupJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupJobName'", id.BackupJobName, "backupJobValue") + } +} + +func TestFormatBackupJobID(t *testing.T) { + actual := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupJobName: "backupJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupJobName: "backupJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue/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/vAuLtVaLuE/bAcKuPjObS/bAcKuPjObVaLuE", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupJobName: "bAcKuPjObVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPjObS/bAcKuPjObVaLuE/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-02-01/jobdetails/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/method_get_autorest.go new file mode 100644 index 00000000000..aa3589e2635 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azureiaasvmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmerrorinfo.go new file mode 100644 index 00000000000..47de469765b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azureiaasvmjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjob.go new file mode 100644 index 00000000000..fd829774cff --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjob.go @@ -0,0 +1,81 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/jobdetails/model_azureiaasvmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjobextendedinfo.go new file mode 100644 index 00000000000..4dba88ce53a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azureiaasvmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjobtaskdetails.go new file mode 100644 index 00000000000..ae1cc624792 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azureiaasvmjobv2.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjobv2.go new file mode 100644 index 00000000000..e1c8f8a8d74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureiaasvmjobv2.go @@ -0,0 +1,80 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/jobdetails/model_azurestorageerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestorageerrorinfo.go new file mode 100644 index 00000000000..28cf64eae5f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azurestoragejob.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestoragejob.go new file mode 100644 index 00000000000..ae1214a2ed0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestoragejob.go @@ -0,0 +1,81 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/jobdetails/model_azurestoragejobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestoragejobextendedinfo.go new file mode 100644 index 00000000000..b687b944e42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azurestoragejobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azurestoragejobtaskdetails.go new file mode 100644 index 00000000000..9cc5cb916c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azureworkloaderrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloaderrorinfo.go new file mode 100644 index 00000000000..d54f4b2217f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azureworkloadjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloadjob.go new file mode 100644 index 00000000000..90c833a0b9e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloadjob.go @@ -0,0 +1,79 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/jobdetails/model_azureworkloadjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloadjobextendedinfo.go new file mode 100644 index 00000000000..b086f0ffee5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_azureworkloadjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_azureworkloadjobtaskdetails.go new file mode 100644 index 00000000000..b6d9349f0c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_dpmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmerrorinfo.go new file mode 100644 index 00000000000..987eb3a7bcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_dpmjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmjob.go new file mode 100644 index 00000000000..7a18a1855d9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmjob.go @@ -0,0 +1,82 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/jobdetails/model_dpmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmjobextendedinfo.go new file mode 100644 index 00000000000..e06f6f2aa5e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_dpmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_dpmjobtaskdetails.go new file mode 100644 index 00000000000..9b8583d9233 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_job.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_job.go new file mode 100644 index 00000000000..eb88a4b64f5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_job.go @@ -0,0 +1,101 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["jobType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawJobImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_jobresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_jobresource.go new file mode 100644 index 00000000000..5a450efbfbd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_jobresource.go @@ -0,0 +1,50 @@ +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 { + type alias JobResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into JobResource: %+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-02-01/jobdetails/model_maberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_maberrorinfo.go new file mode 100644 index 00000000000..d12afd9a026 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_mabjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_mabjob.go new file mode 100644 index 00000000000..b39dc7f470f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_mabjob.go @@ -0,0 +1,81 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/jobdetails/model_mabjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_mabjobextendedinfo.go new file mode 100644 index 00000000000..b08829e160a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_mabjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_mabjobtaskdetails.go new file mode 100644 index 00000000000..c923d5d3282 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_vaultjob.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_vaultjob.go new file mode 100644 index 00000000000..e5aef51bd7b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_vaultjob.go @@ -0,0 +1,78 @@ +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"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +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-02-01/jobdetails/model_vaultjoberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_vaultjoberrorinfo.go new file mode 100644 index 00000000000..8369add63df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/model_vaultjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/model_vaultjobextendedinfo.go new file mode 100644 index 00000000000..78248901487 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobdetails/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/version.go new file mode 100644 index 00000000000..18d90ccf74a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobdetails/version.go @@ -0,0 +1,12 @@ +package jobdetails + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/jobdetails/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/jobs/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobs/client.go new file mode 100644 index 00000000000..fd4e7899bb5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobs/id_vault.go new file mode 100644 index 00000000000..6607977d834 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobs/id_vault.go @@ -0,0 +1,125 @@ +package jobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/jobs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobs/id_vault_test.go new file mode 100644 index 00000000000..d17765be948 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/jobs/method_export_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobs/method_export_autorest.go new file mode 100644 index 00000000000..d6662857fa9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/jobs/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/jobs/version.go new file mode 100644 index 00000000000..4fa8501df19 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/jobs/version.go @@ -0,0 +1,12 @@ +package jobs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/jobs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/operation/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/operation/README.md new file mode 100644 index 00000000000..29328fb9796 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/operation` Documentation + +The `operation` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +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-02-01/operation/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/client.go new file mode 100644 index 00000000000..3a57d0e0d4c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/constants.go new file mode 100644 index 00000000000..6115c6303c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/constants.go @@ -0,0 +1,272 @@ +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-02-01/operation/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/id_vault.go new file mode 100644 index 00000000000..444c958b0df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/id_vault.go @@ -0,0 +1,125 @@ +package operation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/operation/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/id_vault_test.go new file mode 100644 index 00000000000..dbfd98acc85 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/operation/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/method_validate_autorest.go new file mode 100644 index 00000000000..05bac629ddd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..514f189931b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azurefilesharerestorerequest.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/operation/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..b6eff20bd07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/operation/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..32b095a0fc2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadrestorerequest.go @@ -0,0 +1,49 @@ +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 +} + +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-02-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..c96cd65e1df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..edc080d54e0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,51 @@ +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 +} + +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-02-01/operation/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..65edc798c83 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,49 @@ +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 +} + +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-02-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..db723203133 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/operation/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..8ce9cfa2870 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,53 @@ +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 +} + +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-02-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..c6295a99f00 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,54 @@ +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 +} + +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-02-01/operation/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..09c78408995 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,52 @@ +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 +} + +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-02-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..3fad10a2732 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,53 @@ +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 +} + +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-02-01/operation/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_encryptiondetails.go new file mode 100644 index 00000000000..64f3372dbd2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_errordetail.go new file mode 100644 index 00000000000..2c609c87024 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_extendedlocation.go new file mode 100644 index 00000000000..42ab6a6a9d4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..373a26215f3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_iaasvmrestorerequest.go @@ -0,0 +1,65 @@ +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 +} + +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-02-01/operation/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..88a76804099 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,66 @@ +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 +} + +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-02-01/operation/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..dd5d66a7e1c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_identityinfo.go new file mode 100644 index 00000000000..e6971151557 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..d5d028a3fe7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_restorefilespecs.go new file mode 100644 index 00000000000..74e8852a5f7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_restorerequest.go new file mode 100644 index 00000000000..80db41827d3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_restorerequest.go @@ -0,0 +1,149 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawRestoreRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_securedvmdetails.go new file mode 100644 index 00000000000..3f5c4c4f17a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..100aca8fc56 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..9de6dd3d184 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..56b7218e6de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..a900401068b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_targetrestoreinfo.go new file mode 100644 index 00000000000..4d4171906ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..d0776af4b85 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..4000e7813ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_validateiaasvmrestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateiaasvmrestoreoperationrequest.go new file mode 100644 index 00000000000..1e08498a231 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateiaasvmrestoreoperationrequest.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 _ ValidateOperationRequest = ValidateIaasVMRestoreOperationRequest{} + +type ValidateIaasVMRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest +} + +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 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-02-01/operation/model_validateoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationrequest.go new file mode 100644 index 00000000000..7b2def35886 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationrequest.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawValidateOperationRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationrequestresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationrequestresource.go new file mode 100644 index 00000000000..2c0371a7699 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationrequestresource.go @@ -0,0 +1,40 @@ +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 { + type alias ValidateOperationRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ValidateOperationRequestResource: %+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-02-01/operation/model_validateoperationresponse.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationresponse.go new file mode 100644 index 00000000000..0be2ef4af18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_validateoperationsresponse.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validateoperationsresponse.go new file mode 100644 index 00000000000..8b9f3991c07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/operation/model_validaterestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validaterestoreoperationrequest.go new file mode 100644 index 00000000000..5fe10835e45 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/model_validaterestoreoperationrequest.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 _ ValidateOperationRequest = ValidateRestoreOperationRequest{} + +type ValidateRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest +} + +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 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-02-01/operation/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/operation/version.go new file mode 100644 index 00000000000..a177bb1853c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/operation/version.go @@ -0,0 +1,12 @@ +package operation + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/operation/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/README.md new file mode 100644 index 00000000000..914fe9d3031 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection` Documentation + +The `privateendpointconnection` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "privateEndpointConnectionValue") + +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", "vaultValue", "privateEndpointConnectionValue") + +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", "vaultValue", "privateEndpointConnectionValue") + +payload := privateendpointconnection.PrivateEndpointConnectionResource{ + // ... +} + + +if err := client.PutThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/client.go new file mode 100644 index 00000000000..6acd77b913c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/privateendpointconnection/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/constants.go new file mode 100644 index 00000000000..656d9100fa4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/constants.go @@ -0,0 +1,105 @@ +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-02-01/privateendpointconnection/id_privateendpointconnection.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/id_privateendpointconnection.go new file mode 100644 index 00000000000..74a1d16bea8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/id_privateendpointconnection.go @@ -0,0 +1,134 @@ +package privateendpointconnection + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// 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-02-01/privateendpointconnection/id_privateendpointconnection_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..acb07fdeba7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "privateEndpointConnectionValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue/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/vAuLtVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/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-02-01/privateendpointconnection/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/method_delete_autorest.go new file mode 100644 index 00000000000..7e8532d71b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/privateendpointconnection/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/method_get_autorest.go new file mode 100644 index 00000000000..d5309175155 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/privateendpointconnection/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/method_put_autorest.go new file mode 100644 index 00000000000..072a1c747d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/privateendpointconnection/model_privateendpoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/model_privateendpoint.go new file mode 100644 index 00000000000..36d044c72d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/privateendpointconnection/model_privateendpointconnection.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/model_privateendpointconnection.go new file mode 100644 index 00000000000..0acbbb1f932 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/privateendpointconnection/model_privateendpointconnectionresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/model_privateendpointconnectionresource.go new file mode 100644 index 00000000000..e3f0f4f5c74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..81c55145a70 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/privateendpointconnection/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/version.go new file mode 100644 index 00000000000..018cf8e011a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/privateendpointconnection/version.go @@ -0,0 +1,12 @@ +package privateendpointconnection + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/privateendpointconnection/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/README.md new file mode 100644 index 00000000000..4cb422a6892 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers` Documentation + +The `protectablecontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue") + +// 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-02-01/protectablecontainers/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/client.go new file mode 100644 index 00000000000..3d5274d457a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectablecontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/constants.go new file mode 100644 index 00000000000..7d347c78755 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/constants.go @@ -0,0 +1,131 @@ +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-02-01/protectablecontainers/id_backupfabric.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/id_backupfabric.go new file mode 100644 index 00000000000..f20524c3c56 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/id_backupfabric.go @@ -0,0 +1,134 @@ +package protectablecontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupFabricId{} + +// BackupFabricId is a struct representing the Resource ID for a Backup Fabric +type BackupFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string +} + +// NewBackupFabricID returns a new BackupFabricId struct +func NewBackupFabricID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string) BackupFabricId { + return BackupFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + } +} + +// ParseBackupFabricID parses 'input' into a BackupFabricId +func ParseBackupFabricID(input string) (*BackupFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + } +} + +// String returns a human-readable description of this Backup Fabric ID +func (id BackupFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + } + return fmt.Sprintf("Backup Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/id_backupfabric_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/id_backupfabric_test.go new file mode 100644 index 00000000000..9743a82705c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } +} + +func TestFormatBackupFabricID(t *testing.T) { + actual := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/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-02-01/protectablecontainers/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/method_list_autorest.go new file mode 100644 index 00000000000..bdea7c60f0c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectablecontainers/model_azurestorageprotectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_azurestorageprotectablecontainer.go new file mode 100644 index 00000000000..138e03f203a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_azurestorageprotectablecontainer.go @@ -0,0 +1,44 @@ +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"` +} + +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-02-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go new file mode 100644 index 00000000000..ea902c91b28 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go @@ -0,0 +1,44 @@ +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"` +} + +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-02-01/protectablecontainers/model_protectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_protectablecontainer.go new file mode 100644 index 00000000000..52366aa9b98 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_protectablecontainer.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["protectableContainerType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawProtectableContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_protectablecontainerresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_protectablecontainerresource.go new file mode 100644 index 00000000000..c4d67d07b27 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/model_protectablecontainerresource.go @@ -0,0 +1,50 @@ +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 { + type alias ProtectableContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectableContainerResource: %+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-02-01/protectablecontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/predicates.go new file mode 100644 index 00000000000..8ce6de2e8ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectablecontainers/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/version.go new file mode 100644 index 00000000000..739a8d3083a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectablecontainers/version.go @@ -0,0 +1,12 @@ +package protectablecontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectablecontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/README.md new file mode 100644 index 00000000000..ba71df835ad --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/README.md @@ -0,0 +1,73 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems` Documentation + +The `protecteditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-01/protecteditems" +``` + + +### Client Initialization + +```go +client := protecteditems.NewProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectedItemsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +payload := protecteditems.ProtectedItemResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectedItemsClient.Delete` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectedItemsClient.Get` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +read, err := client.Get(ctx, id, protecteditems.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/client.go new file mode 100644 index 00000000000..6843a00f823 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/constants.go new file mode 100644 index 00000000000..622b31da48b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/constants.go @@ -0,0 +1,387 @@ +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-02-01/protecteditems/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/id_protecteditem.go new file mode 100644 index 00000000000..5310c6f6dbc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/id_protecteditem.go @@ -0,0 +1,152 @@ +package protecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/id_protecteditem_test.go new file mode 100644 index 00000000000..3101e1c2911 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/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-02-01/protecteditems/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/method_createorupdate_autorest.go new file mode 100644 index 00000000000..22eeaf22b56 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package protecteditems + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *ProtectedItemResource +} + +// CreateOrUpdate ... +func (c ProtectedItemsClient) CreateOrUpdate(ctx context.Context, id ProtectedItemId, input ProtectedItemResource) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ProtectedItemsClient) preparerForCreateOrUpdate(ctx context.Context, id ProtectedItemId, input ProtectedItemResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ProtectedItemsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/method_delete_autorest.go new file mode 100644 index 00000000000..ed0ba3ec7a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/method_get_autorest.go new file mode 100644 index 00000000000..feb41aa7dcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_azurefileshareprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurefileshareprotecteditem.go new file mode 100644 index 00000000000..4a8bcc205f7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurefileshareprotecteditem.go @@ -0,0 +1,92 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureFileshareProtectedItem{} + +type AzureFileshareProtectedItem struct { + ExtendedInfo *AzureFileshareProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureFileshareProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureFileshareProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureFileshareProtectedItem{} + +func (s AzureFileshareProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileshareProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileshareProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileshareProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureFileShareProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileshareProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go new file mode 100644 index 00000000000..f3ee3ce37c0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go new file mode 100644 index 00000000000..b51e15f7de7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go @@ -0,0 +1,97 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSClassicComputeVMProtectedItem{} + +type AzureIaaSClassicComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectedItem{} + +func (s AzureIaaSClassicComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaascomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaascomputevmprotecteditem.go new file mode 100644 index 00000000000..154e875f0d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaascomputevmprotecteditem.go @@ -0,0 +1,97 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSComputeVMProtectedItem{} + +type AzureIaaSComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectedItem{} + +func (s AzureIaaSComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasvmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasvmprotecteditem.go new file mode 100644 index 00000000000..a328c909a54 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasvmprotecteditem.go @@ -0,0 +1,97 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSVMProtectedItem{} + +type AzureIaaSVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSVMProtectedItem{} + +func (s AzureIaaSVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureIaaSVMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..36c092fb410 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_azuresqlprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azuresqlprotecteditem.go new file mode 100644 index 00000000000..1af6fd59264 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azuresqlprotecteditem.go @@ -0,0 +1,88 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureSqlProtectedItem{} + +type AzureSqlProtectedItem struct { + ExtendedInfo *AzureSqlProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureSqlProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureSqlProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureSqlProtectedItem{} + +func (s AzureSqlProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Sql/servers/databases" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go new file mode 100644 index 00000000000..3b6ba503042 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_azurevmworkloadprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadprotecteditem.go new file mode 100644 index 00000000000..234b099a17b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go new file mode 100644 index 00000000000..e51960b91cf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go new file mode 100644 index 00000000000..f2756534346 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go new file mode 100644 index 00000000000..deb8fd3e6e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go new file mode 100644 index 00000000000..b055967910f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go new file mode 100644 index 00000000000..8a644318f7a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go @@ -0,0 +1,99 @@ +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"` + 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 (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-02-01/protecteditems/model_diskexclusionproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_diskexclusionproperties.go new file mode 100644 index 00000000000..17d722bc609 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_distributednodesinfo.go new file mode 100644 index 00000000000..a67db74854b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_dpmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_dpmprotecteditem.go new file mode 100644 index 00000000000..eb37672a633 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_dpmprotecteditem.go @@ -0,0 +1,89 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = DPMProtectedItem{} + +type DPMProtectedItem struct { + BackupEngineName *string `json:"backupEngineName,omitempty"` + ExtendedInfo *DPMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *DPMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *DPMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = DPMProtectedItem{} + +func (s DPMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper DPMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DPMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DPMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "DPMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DPMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_dpmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_dpmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..fc6f9e8cd52 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_errordetail.go new file mode 100644 index 00000000000..e3fa04c50a3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_extendedproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_extendedproperties.go new file mode 100644 index 00000000000..fe926ccaa09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_genericprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_genericprotecteditem.go new file mode 100644 index 00000000000..b3bc228cfd9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_genericprotecteditem.go @@ -0,0 +1,91 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = GenericProtectedItem{} + +type GenericProtectedItem struct { + FabricName *string `json:"fabricName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + ProtectedItemId *int64 `json:"protectedItemId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + SourceAssociations *map[string]string `json:"sourceAssociations,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *GenericProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *GenericProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = GenericProtectedItem{} + +func (s GenericProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "GenericProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_kpiresourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_kpiresourcehealthdetails.go new file mode 100644 index 00000000000..6cef5da3613 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_mabfilefolderprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_mabfilefolderprotecteditem.go new file mode 100644 index 00000000000..5e1cd167706 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_mabfilefolderprotecteditem.go @@ -0,0 +1,92 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = MabFileFolderProtectedItem{} + +type MabFileFolderProtectedItem struct { + ComputerName *string `json:"computerName,omitempty"` + DeferredDeleteSyncTimeInUTC *int64 `json:"deferredDeleteSyncTimeInUTC,omitempty"` + ExtendedInfo *MabFileFolderProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *MabFileFolderProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *MabFileFolderProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = MabFileFolderProtectedItem{} + +func (s MabFileFolderProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper MabFileFolderProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabFileFolderProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabFileFolderProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "MabFileFolderProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabFileFolderProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go new file mode 100644 index 00000000000..fbb9afca971 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/model_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_protecteditem.go new file mode 100644 index 00000000000..ffceef4149c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_protecteditem.go @@ -0,0 +1,149 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalProtectedItemImplementation(input []byte) (ProtectedItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectedItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectedItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareProtectedItem") { + var out AzureFileshareProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileshareProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMProtectedItem") { + var out AzureIaaSVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Sql/servers/databases") { + var out AzureSqlProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectedItem") { + var out AzureVMWorkloadProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPAseDatabase") { + var out AzureVMWorkloadSAPAseDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "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 + } + + out := RawProtectedItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_protecteditemresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_protecteditemresource.go new file mode 100644 index 00000000000..0541c1a67ba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_protecteditemresource.go @@ -0,0 +1,50 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectedItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectedItemResource{} + +func (s *ProtectedItemResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectedItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectedItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectedItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectedItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectedItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_resourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/model_resourcehealthdetails.go new file mode 100644 index 00000000000..86710207857 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protecteditems/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/version.go new file mode 100644 index 00000000000..7c0807b4e8c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protecteditems/version.go @@ -0,0 +1,12 @@ +package protecteditems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protecteditems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/README.md new file mode 100644 index 00000000000..72688618816 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/README.md @@ -0,0 +1,101 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers` Documentation + +The `protectioncontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-01/protectioncontainers" +``` + + +### Client Initialization + +```go +client := protectioncontainers.NewProtectionContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectionContainersClient.Get` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Inquire` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Inquire(ctx, id, protectioncontainers.DefaultInquireOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Refresh` + +```go +ctx := context.TODO() +id := protectioncontainers.NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue") + +read, err := client.Refresh(ctx, id, protectioncontainers.DefaultRefreshOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Register` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +payload := protectioncontainers.ProtectionContainerResource{ + // ... +} + + +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", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Unregister(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/client.go new file mode 100644 index 00000000000..a3766493d9d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/constants.go new file mode 100644 index 00000000000..db706b5bd09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/constants.go @@ -0,0 +1,330 @@ +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-02-01/protectioncontainers/id_backupfabric.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_backupfabric.go new file mode 100644 index 00000000000..227ddab1f9b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_backupfabric.go @@ -0,0 +1,134 @@ +package protectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupFabricId{} + +// BackupFabricId is a struct representing the Resource ID for a Backup Fabric +type BackupFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string +} + +// NewBackupFabricID returns a new BackupFabricId struct +func NewBackupFabricID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string) BackupFabricId { + return BackupFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + } +} + +// ParseBackupFabricID parses 'input' into a BackupFabricId +func ParseBackupFabricID(input string) (*BackupFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + } +} + +// String returns a human-readable description of this Backup Fabric ID +func (id BackupFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + } + return fmt.Sprintf("Backup Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_backupfabric_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_backupfabric_test.go new file mode 100644 index 00000000000..37a949bab5f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } +} + +func TestFormatBackupFabricID(t *testing.T) { + actual := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/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-02-01/protectioncontainers/id_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_protectioncontainer.go new file mode 100644 index 00000000000..03e512bfe43 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_protectioncontainer.go @@ -0,0 +1,143 @@ +package protectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectionContainerId{} + +// ProtectionContainerId is a struct representing the Resource ID for a Protection Container +type ProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string +} + +// NewProtectionContainerID returns a new ProtectionContainerId struct +func NewProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string) ProtectionContainerId { + return ProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + } +} + +// ParseProtectionContainerID parses 'input' into a ProtectionContainerId +func ParseProtectionContainerID(input string) (*ProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + } +} + +// String returns a human-readable description of this Protection Container ID +func (id ProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + } + return fmt.Sprintf("Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_protectioncontainer_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/id_protectioncontainer_test.go new file mode 100644 index 00000000000..2e1ac683e43 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } +} + +func TestFormatProtectionContainerID(t *testing.T) { + actual := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/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-02-01/protectioncontainers/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_get_autorest.go new file mode 100644 index 00000000000..07d4c710143 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/method_inquire_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_inquire_autorest.go new file mode 100644 index 00000000000..fb85971bffd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/method_refresh_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_refresh_autorest.go new file mode 100644 index 00000000000..2b4984af995 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/method_register_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_register_autorest.go new file mode 100644 index 00000000000..c1408bad011 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/method_unregister_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/method_unregister_autorest.go new file mode 100644 index 00000000000..cf4fbebe128 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..1c21d8906f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurebackupservercontainer.go @@ -0,0 +1,53 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureBackupServerContainer{} + +type AzureBackupServerContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureBackupServerContainer{} + +func (s AzureBackupServerContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerContainer: %+v", err) + } + decoded["containerType"] = "AzureBackupServerContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..b8a8c17717e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSClassicComputeVMContainer{} + +type AzureIaaSClassicComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMContainer{} + +func (s AzureIaaSClassicComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..c66beff2ce0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSComputeVMContainer{} + +type AzureIaaSComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMContainer{} + +func (s AzureIaaSComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..7e0a1ed3e94 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSQLAGWorkloadContainerProtectionContainer{} + +type AzureSQLAGWorkloadContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSQLAGWorkloadContainerProtectionContainer{} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSQLAGWorkloadContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "SQLAGWorkLoadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..cd29b673055 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azuresqlcontainer.go @@ -0,0 +1,45 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSqlContainer{} + +type AzureSqlContainer struct { + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSqlContainer{} + +func (s AzureSqlContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlContainer: %+v", err) + } + decoded["containerType"] = "AzureSqlContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..fc4de5fe940 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurestoragecontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureStorageContainer{} + +type AzureStorageContainer struct { + AcquireStorageAccountLock *AcquireStorageAccountLock `json:"acquireStorageAccountLock,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureStorageContainer{} + +func (s AzureStorageContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageContainer: %+v", err) + } + decoded["containerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..97d2dbf49f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureVMAppContainerProtectionContainer{} + +type AzureVMAppContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureVMAppContainerProtectionContainer{} + +func (s AzureVMAppContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..79290339156 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureworkloadcontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureWorkloadContainer{} + +type AzureWorkloadContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainer{} + +func (s AzureWorkloadContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainer: %+v", err) + } + decoded["containerType"] = "AzureWorkloadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..3306d7014ef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..2a757b599d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..a6ba705e4d5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..d35b9a9844d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_dpmcontainer.go @@ -0,0 +1,53 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = DpmContainer{} + +type DpmContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = DpmContainer{} + +func (s DpmContainer) MarshalJSON() ([]byte, error) { + type wrapper DpmContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmContainer: %+v", err) + } + decoded["containerType"] = "DPMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..608a1ba48f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_errordetail.go new file mode 100644 index 00000000000..6eac856c404 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_genericcontainer.go new file mode 100644 index 00000000000..45b661347c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_genericcontainer.go @@ -0,0 +1,47 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = GenericContainer{} + +type GenericContainer struct { + ExtendedInformation *GenericContainerExtendedInfo `json:"extendedInformation,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = GenericContainer{} + +func (s GenericContainer) MarshalJSON() ([]byte, error) { + type wrapper GenericContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericContainer: %+v", err) + } + decoded["containerType"] = "GenericContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..6d1b2f49b6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..e0a2bd35149 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_iaasvmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = IaaSVMContainer{} + +type IaaSVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = IaaSVMContainer{} + +func (s IaaSVMContainer) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMContainer: %+v", err) + } + decoded["containerType"] = "IaasVMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..53bfc1db911 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..195ee612f4e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_mabcontainer.go new file mode 100644 index 00000000000..b2d5eb97307 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_mabcontainer.go @@ -0,0 +1,52 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = MabContainer{} + +type MabContainer struct { + AgentVersion *string `json:"agentVersion,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerHealthState *string `json:"containerHealthState,omitempty"` + ContainerId *int64 `json:"containerId,omitempty"` + ExtendedInfo *MabContainerExtendedInfo `json:"extendedInfo,omitempty"` + MabContainerHealthDetails *[]MABContainerHealthDetails `json:"mabContainerHealthDetails,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = MabContainer{} + +func (s MabContainer) MarshalJSON() ([]byte, error) { + type wrapper MabContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabContainer: %+v", err) + } + decoded["containerType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..82aeca609c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..1bc3a807285 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..1ba03b16172 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_protectioncontainer.go @@ -0,0 +1,141 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionContainerImplementation(input []byte) (ProtectionContainer, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionContainer into map[string]interface: %+v", err) + } + + value, ok := temp["containerType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupServerContainer") { + var out AzureBackupServerContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAGWorkLoadContainer") { + var out AzureSQLAGWorkloadContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSqlContainer") { + var out AzureSqlContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainer") { + var out AzureWorkloadContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMContainer") { + var out DpmContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericContainer") { + var out GenericContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMContainer") { + var out IaaSVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out MabContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabContainer: %+v", err) + } + return out, nil + } + + out := RawProtectionContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..4de75e08602 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_protectioncontainerresource.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionContainer `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionContainerResource{} + +func (s *ProtectionContainerResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionContainerResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionContainerResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..1e9d1413743 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectioncontainers/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/version.go new file mode 100644 index 00000000000..e3dd1b2afe4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectioncontainers/version.go @@ -0,0 +1,12 @@ +package protectioncontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectioncontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/README.md new file mode 100644 index 00000000000..1af1272222d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/README.md @@ -0,0 +1,94 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent` Documentation + +The `protectionintent` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue", "backupProtectionIntentValue") + +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", "vaultValue", "backupFabricValue", "backupProtectionIntentValue") + +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", "vaultValue", "backupFabricValue", "backupProtectionIntentValue") + +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", "locationValue") + +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-02-01/protectionintent/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/client.go new file mode 100644 index 00000000000..0ffe385d61d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionintent/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/constants.go new file mode 100644 index 00000000000..2d2e274187f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/constants.go @@ -0,0 +1,279 @@ +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-02-01/protectionintent/id_backupprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_backupprotectionintent.go new file mode 100644 index 00000000000..a96f9675ff5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_backupprotectionintent.go @@ -0,0 +1,143 @@ +package protectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticBackupProtectionIntent", "backupProtectionIntent", "backupProtectionIntent"), + resourceids.UserSpecifiedSegment("backupProtectionIntentName", "backupProtectionIntentValue"), + } +} + +// 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-02-01/protectionintent/id_backupprotectionintent_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_backupprotectionintent_test.go new file mode 100644 index 00000000000..acc775f1aef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "backupProtectionIntentValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.BackupProtectionIntentName != "backupProtectionIntentValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupProtectionIntentName'", id.BackupProtectionIntentName, "backupProtectionIntentValue") + } +} + +func TestFormatBackupProtectionIntentID(t *testing.T) { + actual := NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "backupProtectionIntentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + BackupProtectionIntentName: "backupProtectionIntentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/bAcKuPpRoTeCtIoNiNtEnT", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + BackupProtectionIntentName: "backupProtectionIntentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/bAcKuPpRoTeCtIoNiNtEnT/bAcKuPpRoTeCtIoNiNtEnTvAlUe", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + BackupProtectionIntentName: "bAcKuPpRoTeCtIoNiNtEnTvAlUe", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/bAcKuPpRoTeCtIoNiNtEnT/bAcKuPpRoTeCtIoNiNtEnTvAlUe/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-02-01/protectionintent/id_location.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_location.go new file mode 100644 index 00000000000..295c6aacaa3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_location.go @@ -0,0 +1,116 @@ +package protectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "locationValue"), + } +} + +// 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-02-01/protectionintent/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/id_location_test.go new file mode 100644 index 00000000000..76b7dbb1a81 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "locationValue") + + 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 != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue" + 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/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/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/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe/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-02-01/protectionintent/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/method_createorupdate_autorest.go new file mode 100644 index 00000000000..119b9b9a38a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionintent/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/method_delete_autorest.go new file mode 100644 index 00000000000..2ed03771624 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionintent/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/method_get_autorest.go new file mode 100644 index 00000000000..0875ecb9ece --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionintent/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/method_validate_autorest.go new file mode 100644 index 00000000000..677f74de02b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go new file mode 100644 index 00000000000..06a58c50499 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go @@ -0,0 +1,45 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/protectionintent/model_azureresourceprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureresourceprotectionintent.go new file mode 100644 index 00000000000..6a274d6f965 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureresourceprotectionintent.go @@ -0,0 +1,46 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/protectionintent/model_azureworkloadautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadautoprotectionintent.go new file mode 100644 index 00000000000..c3bd647eb31 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadautoprotectionintent.go @@ -0,0 +1,45 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go new file mode 100644 index 00000000000..392bf620c14 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go @@ -0,0 +1,45 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go new file mode 100644 index 00000000000..c794a5ef4db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go @@ -0,0 +1,46 @@ +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"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +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-02-01/protectionintent/model_prevalidateenablebackuprequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_prevalidateenablebackuprequest.go new file mode 100644 index 00000000000..58ac0096b74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionintent/model_prevalidateenablebackupresponse.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_prevalidateenablebackupresponse.go new file mode 100644 index 00000000000..456761b757d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionintent/model_protectionintent.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_protectionintent.go new file mode 100644 index 00000000000..a7fa1d6491f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_protectionintent.go @@ -0,0 +1,85 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["protectionIntentItemType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawProtectionIntentImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_protectionintentresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_protectionintentresource.go new file mode 100644 index 00000000000..bff822af9f5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/model_protectionintentresource.go @@ -0,0 +1,50 @@ +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 { + type alias ProtectionIntentResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionIntentResource: %+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-02-01/protectionintent/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/version.go new file mode 100644 index 00000000000..8e0fb6f32d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionintent/version.go @@ -0,0 +1,12 @@ +package protectionintent + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectionintent/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/README.md new file mode 100644 index 00000000000..86079fbc1c3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies` Documentation + +The `protectionpolicies` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-01/protectionpolicies" +``` + + +### Client Initialization + +```go +client := protectionpolicies.NewProtectionPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectionPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +payload := protectionpolicies.ProtectionPolicyResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProtectionPoliciesClient.Get` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/client.go new file mode 100644 index 00000000000..af96d5ee4b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/constants.go new file mode 100644 index 00000000000..0b1721c13dc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/constants.go @@ -0,0 +1,458 @@ +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-02-01/protectionpolicies/id_backuppolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/id_backuppolicy.go new file mode 100644 index 00000000000..332daf18c84 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/id_backuppolicy.go @@ -0,0 +1,134 @@ +package protectionpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupPolicyId{} + +// BackupPolicyId is a struct representing the Resource ID for a Backup Policy +type BackupPolicyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupPolicyName string +} + +// NewBackupPolicyID returns a new BackupPolicyId struct +func NewBackupPolicyID(subscriptionId string, resourceGroupName string, vaultName string, backupPolicyName string) BackupPolicyId { + return BackupPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupPolicyName: backupPolicyName, + } +} + +// ParseBackupPolicyID parses 'input' into a BackupPolicyId +func ParseBackupPolicyID(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupPolicies", "backupPolicies", "backupPolicies"), + resourceids.UserSpecifiedSegment("backupPolicyName", "backupPolicyValue"), + } +} + +// String returns a human-readable description of this Backup Policy ID +func (id BackupPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Policy Name: %q", id.BackupPolicyName), + } + return fmt.Sprintf("Backup Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/id_backuppolicy_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/id_backuppolicy_test.go new file mode 100644 index 00000000000..208670abbef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupPolicyValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupPolicyName != "backupPolicyValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupPolicyName'", id.BackupPolicyName, "backupPolicyValue") + } +} + +func TestFormatBackupPolicyID(t *testing.T) { + actual := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupPolicyName: "backupPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupPolicyName: "backupPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue/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/vAuLtVaLuE/bAcKuPpOlIcIeS/bAcKuPpOlIcYvAlUe", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupPolicyName: "bAcKuPpOlIcYvAlUe", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPpOlIcIeS/bAcKuPpOlIcYvAlUe/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-02-01/protectionpolicies/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/method_createorupdate_autorest.go new file mode 100644 index 00000000000..a10287d2ffc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package protectionpolicies + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionPolicyResource +} + +// CreateOrUpdate ... +func (c ProtectionPoliciesClient) CreateOrUpdate(ctx context.Context, id BackupPolicyId, input ProtectionPolicyResource) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ProtectionPoliciesClient) preparerForCreateOrUpdate(ctx context.Context, id BackupPolicyId, input ProtectionPolicyResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ProtectionPoliciesClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/method_delete_autorest.go new file mode 100644 index 00000000000..d8310df327c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/method_get_autorest.go new file mode 100644 index 00000000000..bd3aabebfe7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_azurefileshareprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azurefileshareprotectionpolicy.go new file mode 100644 index 00000000000..90fb6638062 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azurefileshareprotectionpolicy.go @@ -0,0 +1,85 @@ +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 + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureFileShareProtectionPolicy{} + +func (s AzureFileShareProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureStorage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureFileShareProtectionPolicy{} + +func (s *AzureFileShareProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureFileShareProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.TimeZone = decoded.TimeZone + s.VaultRetentionPolicy = decoded.VaultRetentionPolicy + s.WorkLoadType = decoded.WorkLoadType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go new file mode 100644 index 00000000000..cec013785db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go @@ -0,0 +1,91 @@ +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 + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureIaaSVMProtectionPolicy{} + +func (s AzureIaaSVMProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureIaasVM" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureIaaSVMProtectionPolicy{} + +func (s *AzureIaaSVMProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureIaaSVMProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + + s.InstantRPDetails = decoded.InstantRPDetails + s.InstantRpRetentionRangeInDays = decoded.InstantRpRetentionRangeInDays + s.PolicyType = decoded.PolicyType + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.SnapshotConsistencyType = decoded.SnapshotConsistencyType + s.TieringPolicy = decoded.TieringPolicy + s.TimeZone = decoded.TimeZone + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azuresqlprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azuresqlprotectionpolicy.go new file mode 100644 index 00000000000..5a691310aaf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azuresqlprotectionpolicy.go @@ -0,0 +1,70 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureSqlProtectionPolicy{} + +type AzureSqlProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureSqlProtectionPolicy{} + +func (s AzureSqlProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureSql" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureSqlProtectionPolicy{} + +func (s *AzureSqlProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureSqlProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureSqlProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureSqlProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go new file mode 100644 index 00000000000..4ad1179dc7c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go @@ -0,0 +1,46 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureVMWorkloadProtectionPolicy{} + +type AzureVMWorkloadProtectionPolicy struct { + MakePolicyConsistent *bool `json:"makePolicyConsistent,omitempty"` + Settings *Settings `json:"settings,omitempty"` + SubProtectionPolicy *[]SubProtectionPolicy `json:"subProtectionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadProtectionPolicy{} + +func (s AzureVMWorkloadProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureWorkload" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_dailyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_dailyretentionformat.go new file mode 100644 index 00000000000..f2f8a9c3693 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_dailyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_dailyretentionschedule.go new file mode 100644 index 00000000000..40dc38fbcda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_dailyschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_dailyschedule.go new file mode 100644 index 00000000000..88826749b25 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_day.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_day.go new file mode 100644 index 00000000000..ca922f3cfe2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_genericprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_genericprotectionpolicy.go new file mode 100644 index 00000000000..c893e4e8051 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_genericprotectionpolicy.go @@ -0,0 +1,45 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = GenericProtectionPolicy{} + +type GenericProtectionPolicy struct { + FabricName *string `json:"fabricName,omitempty"` + SubProtectionPolicy *[]SubProtectionPolicy `json:"subProtectionPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = GenericProtectionPolicy{} + +func (s GenericProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "GenericProtectionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_hourlyschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_hourlyschedule.go new file mode 100644 index 00000000000..8e573c02a5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_instantrpadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_instantrpadditionaldetails.go new file mode 100644 index 00000000000..ea9cd7a24da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_logschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_logschedulepolicy.go new file mode 100644 index 00000000000..8f2cae11901 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_logschedulepolicy.go @@ -0,0 +1,41 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = LogSchedulePolicy{} + +type LogSchedulePolicy struct { + ScheduleFrequencyInMins *int64 `json:"scheduleFrequencyInMins,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = LogSchedulePolicy{} + +func (s LogSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper LogSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LogSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LogSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "LogSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LogSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_longtermretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_longtermretentionpolicy.go new file mode 100644 index 00000000000..50f80900d4e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_longtermretentionpolicy.go @@ -0,0 +1,44 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RetentionPolicy = LongTermRetentionPolicy{} + +type LongTermRetentionPolicy struct { + DailySchedule *DailyRetentionSchedule `json:"dailySchedule,omitempty"` + MonthlySchedule *MonthlyRetentionSchedule `json:"monthlySchedule,omitempty"` + WeeklySchedule *WeeklyRetentionSchedule `json:"weeklySchedule,omitempty"` + YearlySchedule *YearlyRetentionSchedule `json:"yearlySchedule,omitempty"` + + // Fields inherited from RetentionPolicy +} + +var _ json.Marshaler = LongTermRetentionPolicy{} + +func (s LongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + type wrapper LongTermRetentionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LongTermRetentionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LongTermRetentionPolicy: %+v", err) + } + decoded["retentionPolicyType"] = "LongTermRetentionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LongTermRetentionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_longtermschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_longtermschedulepolicy.go new file mode 100644 index 00000000000..06d19a60ab2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_longtermschedulepolicy.go @@ -0,0 +1,40 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = LongTermSchedulePolicy{} + +type LongTermSchedulePolicy struct { + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = LongTermSchedulePolicy{} + +func (s LongTermSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper LongTermSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LongTermSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LongTermSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "LongTermSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LongTermSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_mabprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_mabprotectionpolicy.go new file mode 100644 index 00000000000..4178653c4e6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_mabprotectionpolicy.go @@ -0,0 +1,79 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = MabProtectionPolicy{} + +type MabProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = MabProtectionPolicy{} + +func (s MabProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper MabProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "MAB" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &MabProtectionPolicy{} + +func (s *MabProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias MabProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MabProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'MabProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'MabProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_monthlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_monthlyretentionschedule.go new file mode 100644 index 00000000000..4ceda36d875 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_protectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_protectionpolicy.go new file mode 100644 index 00000000000..7d850fa25bd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_protectionpolicy.go @@ -0,0 +1,93 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionPolicyImplementation(input []byte) (ProtectionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["backupManagementType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureStorage") { + var out AzureFileShareProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaasVM") { + var out AzureIaaSVMProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSql") { + var out AzureSqlProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkload") { + var out AzureVMWorkloadProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectionPolicy") { + var out GenericProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MAB") { + var out MabProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + return out, nil + } + + out := RawProtectionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_protectionpolicyresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_protectionpolicyresource.go new file mode 100644 index 00000000000..03bda4d0a12 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_protectionpolicyresource.go @@ -0,0 +1,50 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicyResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionPolicy `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionPolicyResource{} + +func (s *ProtectionPolicyResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionPolicyResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionPolicyResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionPolicyResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionPolicyResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_retentionduration.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_retentionduration.go new file mode 100644 index 00000000000..4b77b5e2f23 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_retentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_retentionpolicy.go new file mode 100644 index 00000000000..fa52632f677 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_retentionpolicy.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalRetentionPolicyImplementation(input []byte) (RetentionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RetentionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["retentionPolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LongTermRetentionPolicy") { + var out LongTermRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermRetentionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleRetentionPolicy") { + var out SimpleRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleRetentionPolicy: %+v", err) + } + return out, nil + } + + out := RawRetentionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_schedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_schedulepolicy.go new file mode 100644 index 00000000000..6f395ac7fc7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_schedulepolicy.go @@ -0,0 +1,77 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalSchedulePolicyImplementation(input []byte) (SchedulePolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SchedulePolicy into map[string]interface: %+v", err) + } + + value, ok := temp["schedulePolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LogSchedulePolicy") { + var out LogSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LogSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "LongTermSchedulePolicy") { + var out LongTermSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicy") { + var out SimpleSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicyV2") { + var out SimpleSchedulePolicyV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicyV2: %+v", err) + } + return out, nil + } + + out := RawSchedulePolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_settings.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_settings.go new file mode 100644 index 00000000000..585e96708fc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_simpleretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleretentionpolicy.go new file mode 100644 index 00000000000..37edb09a956 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleretentionpolicy.go @@ -0,0 +1,41 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RetentionPolicy = SimpleRetentionPolicy{} + +type SimpleRetentionPolicy struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + + // Fields inherited from RetentionPolicy +} + +var _ json.Marshaler = SimpleRetentionPolicy{} + +func (s SimpleRetentionPolicy) MarshalJSON() ([]byte, error) { + type wrapper SimpleRetentionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleRetentionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleRetentionPolicy: %+v", err) + } + decoded["retentionPolicyType"] = "SimpleRetentionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleRetentionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleschedulepolicy.go new file mode 100644 index 00000000000..117247120b6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleschedulepolicy.go @@ -0,0 +1,45 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = SimpleSchedulePolicy{} + +type SimpleSchedulePolicy struct { + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + ScheduleRunDays *[]DayOfWeek `json:"scheduleRunDays,omitempty"` + ScheduleRunFrequency *ScheduleRunType `json:"scheduleRunFrequency,omitempty"` + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` + ScheduleWeeklyFrequency *int64 `json:"scheduleWeeklyFrequency,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = SimpleSchedulePolicy{} + +func (s SimpleSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper SimpleSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "SimpleSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleschedulepolicyv2.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleschedulepolicyv2.go new file mode 100644 index 00000000000..f522d8d7184 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_simpleschedulepolicyv2.go @@ -0,0 +1,44 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = SimpleSchedulePolicyV2{} + +type SimpleSchedulePolicyV2 struct { + DailySchedule *DailySchedule `json:"dailySchedule,omitempty"` + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + ScheduleRunFrequency *ScheduleRunType `json:"scheduleRunFrequency,omitempty"` + WeeklySchedule *WeeklySchedule `json:"weeklySchedule,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = SimpleSchedulePolicyV2{} + +func (s SimpleSchedulePolicyV2) MarshalJSON() ([]byte, error) { + type wrapper SimpleSchedulePolicyV2 + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleSchedulePolicyV2: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleSchedulePolicyV2: %+v", err) + } + decoded["schedulePolicyType"] = "SimpleSchedulePolicyV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleSchedulePolicyV2: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_snapshotbackupadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_snapshotbackupadditionaldetails.go new file mode 100644 index 00000000000..7ac85d6090e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_subprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_subprotectionpolicy.go new file mode 100644 index 00000000000..f8d86c15304 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_subprotectionpolicy.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. + +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 { + type alias SubProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into SubProtectionPolicy: %+v", err) + } + + s.PolicyType = decoded.PolicyType + s.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-02-01/protectionpolicies/model_tieringpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_tieringpolicy.go new file mode 100644 index 00000000000..51a5c8b97f0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..7345c69f819 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..85ab2cf390a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_vaultretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_vaultretentionpolicy.go new file mode 100644 index 00000000000..51b77729f01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_vaultretentionpolicy.go @@ -0,0 +1,40 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultRetentionPolicy struct { + SnapshotRetentionInDays int64 `json:"snapshotRetentionInDays"` + VaultRetention RetentionPolicy `json:"vaultRetention"` +} + +var _ json.Unmarshaler = &VaultRetentionPolicy{} + +func (s *VaultRetentionPolicy) UnmarshalJSON(bytes []byte) error { + type alias VaultRetentionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into VaultRetentionPolicy: %+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-02-01/protectionpolicies/model_weeklyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_weeklyretentionformat.go new file mode 100644 index 00000000000..082fcf7abe1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_weeklyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_weeklyretentionschedule.go new file mode 100644 index 00000000000..cde2551554d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_weeklyschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_weeklyschedule.go new file mode 100644 index 00000000000..f3005f7015f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/model_yearlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/model_yearlyretentionschedule.go new file mode 100644 index 00000000000..8d300368ef5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/protectionpolicies/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/version.go new file mode 100644 index 00000000000..8ed87ff851f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/protectionpolicies/version.go @@ -0,0 +1,12 @@ +package protectionpolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectionpolicies/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/README.md new file mode 100644 index 00000000000..0bd579e4a09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint` Documentation + +The `recoverypoint` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +payload := recoverypoint.MoveRPAcrossTiersRequest{ + // ... +} + + +if err := client.MoveRecoveryPointThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/client.go new file mode 100644 index 00000000000..6c60cc292bc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoint/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/constants.go new file mode 100644 index 00000000000..90fc0ec9fcd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/constants.go @@ -0,0 +1,40 @@ +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-02-01/recoverypoint/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/id_recoverypoint.go new file mode 100644 index 00000000000..b6d9576995b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/id_recoverypoint.go @@ -0,0 +1,161 @@ +package recoverypoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// 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-02-01/recoverypoint/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/id_recoverypoint_test.go new file mode 100644 index 00000000000..afce76da591 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/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-02-01/recoverypoint/method_moverecoverypoint_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/method_moverecoverypoint_autorest.go new file mode 100644 index 00000000000..77b6f679042 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoint/model_moverpacrosstiersrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/model_moverpacrosstiersrequest.go new file mode 100644 index 00000000000..c90154ae670 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoint/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/version.go new file mode 100644 index 00000000000..3493f1aaab6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoint/version.go @@ -0,0 +1,12 @@ +package recoverypoint + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoverypoint/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/README.md new file mode 100644 index 00000000000..2c06a91a10f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints` Documentation + +The `recoverypoints` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +// 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-02-01/recoverypoints/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/client.go new file mode 100644 index 00000000000..dab85424069 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/constants.go new file mode 100644 index 00000000000..fa65db6e0e8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/constants.go @@ -0,0 +1,151 @@ +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-02-01/recoverypoints/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_protecteditem.go new file mode 100644 index 00000000000..55f57001ba3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_protecteditem.go @@ -0,0 +1,152 @@ +package recoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_protecteditem_test.go new file mode 100644 index 00000000000..60147759c19 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/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-02-01/recoverypoints/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_recoverypoint.go new file mode 100644 index 00000000000..760873ebbc1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_recoverypoint.go @@ -0,0 +1,161 @@ +package recoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// 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-02-01/recoverypoints/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/id_recoverypoint_test.go new file mode 100644 index 00000000000..888c5b072a6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/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-02-01/recoverypoints/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/method_get_autorest.go new file mode 100644 index 00000000000..dce6d176011 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/method_list_autorest.go new file mode 100644 index 00000000000..904ef293b39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_azurefilesharerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azurefilesharerecoverypoint.go new file mode 100644 index 00000000000..2a7c237f200 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azurefilesharerecoverypoint.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go new file mode 100644 index 00000000000..a36ed7d5894 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/recoverypoints/model_azureworkloadrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadrecoverypoint.go new file mode 100644 index 00000000000..a060d0325a6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadrecoverypoint.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go new file mode 100644 index 00000000000..ba3317831d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go new file mode 100644 index 00000000000..3cc6563ceee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go new file mode 100644 index 00000000000..0e54dcb88e5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go @@ -0,0 +1,47 @@ +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 +} + +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-02-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go new file mode 100644 index 00000000000..e4c16a37cbf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go new file mode 100644 index 00000000000..8ad178eb3ba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_bekdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_bekdetails.go new file mode 100644 index 00000000000..36772ad0169 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_diskinformation.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_diskinformation.go new file mode 100644 index 00000000000..1d6ed082bf4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_extendedlocation.go new file mode 100644 index 00000000000..a4b7423fd00 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_genericrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_genericrecoverypoint.go new file mode 100644 index 00000000000..97d3952dc2c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_genericrecoverypoint.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/recoverypoints/model_iaasvmrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_iaasvmrecoverypoint.go new file mode 100644 index 00000000000..dbd1d19b002 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_iaasvmrecoverypoint.go @@ -0,0 +1,61 @@ +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 +} + +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-02-01/recoverypoints/model_kekdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_kekdetails.go new file mode 100644 index 00000000000..36abbae9609 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_keyandsecretdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_keyandsecretdetails.go new file mode 100644 index 00000000000..96c513fc516 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_pointintimerange.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_pointintimerange.go new file mode 100644 index 00000000000..4190258e022 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypoint.go new file mode 100644 index 00000000000..cb819e0f9c5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypoint.go @@ -0,0 +1,117 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawRecoveryPointImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointdiskconfiguration.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointdiskconfiguration.go new file mode 100644 index 00000000000..d3935380d03 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_recoverypointmovereadinessinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointmovereadinessinfo.go new file mode 100644 index 00000000000..03cab067198 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_recoverypointproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointproperties.go new file mode 100644 index 00000000000..4bd3f5e75a3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_recoverypointresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointresource.go new file mode 100644 index 00000000000..8e67217424b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointresource.go @@ -0,0 +1,50 @@ +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 { + type alias RecoveryPointResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPointResource: %+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-02-01/recoverypoints/model_recoverypointtierinformationv2.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_recoverypointtierinformationv2.go new file mode 100644 index 00000000000..996285f0562 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/model_sqldatadirectory.go new file mode 100644 index 00000000000..8460946fc57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/predicates.go new file mode 100644 index 00000000000..c3db33a5e75 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypoints/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/version.go new file mode 100644 index 00000000000..75142e1e3db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypoints/version.go @@ -0,0 +1,12 @@ +package recoverypoints + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoverypoints/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/README.md new file mode 100644 index 00000000000..9b448e54f1e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove` Documentation + +The `recoverypointsrecommendedformove` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +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-02-01/recoverypointsrecommendedformove/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/client.go new file mode 100644 index 00000000000..0f891c24f9b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/constants.go new file mode 100644 index 00000000000..e2e55355df0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/constants.go @@ -0,0 +1,151 @@ +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-02-01/recoverypointsrecommendedformove/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/id_protecteditem.go new file mode 100644 index 00000000000..5628fccd6e3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/id_protecteditem.go @@ -0,0 +1,152 @@ +package recoverypointsrecommendedformove + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/id_protecteditem_test.go new file mode 100644 index 00000000000..a75698ad768 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/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-02-01/recoverypointsrecommendedformove/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/method_list_autorest.go new file mode 100644 index 00000000000..71847a51411 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go new file mode 100644 index 00000000000..3654d6b1bf1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go new file mode 100644 index 00000000000..4b477077a01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go new file mode 100644 index 00000000000..6c7e5f6b958 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go new file mode 100644 index 00000000000..801a86e29aa --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go new file mode 100644 index 00000000000..4ca5f3470d3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go new file mode 100644 index 00000000000..e5030f32945 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go @@ -0,0 +1,47 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go new file mode 100644 index 00000000000..0e441f79cda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go new file mode 100644 index 00000000000..f98b9b7a0b4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_bekdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_bekdetails.go new file mode 100644 index 00000000000..2060eb3fa42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_diskinformation.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_diskinformation.go new file mode 100644 index 00000000000..efce1750999 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_extendedlocation.go new file mode 100644 index 00000000000..04a4089410d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go new file mode 100644 index 00000000000..040a2cf2cc1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go @@ -0,0 +1,45 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go new file mode 100644 index 00000000000..12aa7a9b66b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go @@ -0,0 +1,61 @@ +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 +} + +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-02-01/recoverypointsrecommendedformove/model_kekdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_kekdetails.go new file mode 100644 index 00000000000..a3aeb5f2512 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go new file mode 100644 index 00000000000..65444fc0f49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go new file mode 100644 index 00000000000..0085a2a3b9d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_pointintimerange.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_pointintimerange.go new file mode 100644 index 00000000000..9bb33473707 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypoint.go new file mode 100644 index 00000000000..7cd17561fd8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypoint.go @@ -0,0 +1,117 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawRecoveryPointImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go new file mode 100644 index 00000000000..6ec831b050f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go new file mode 100644 index 00000000000..2f638ab7bcd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_recoverypointproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointproperties.go new file mode 100644 index 00000000000..97af2516cec --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_recoverypointresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointresource.go new file mode 100644 index 00000000000..26a0bbdce62 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointresource.go @@ -0,0 +1,50 @@ +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 { + type alias RecoveryPointResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPointResource: %+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-02-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go new file mode 100644 index 00000000000..6f014df3e1d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/model_sqldatadirectory.go new file mode 100644 index 00000000000..74ae63ba5e5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/predicates.go new file mode 100644 index 00000000000..9f73792f14b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/recoverypointsrecommendedformove/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/version.go new file mode 100644 index 00000000000..956059ea9bb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/recoverypointsrecommendedformove/version.go @@ -0,0 +1,12 @@ +package recoverypointsrecommendedformove + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoverypointsrecommendedformove/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/README.md new file mode 100644 index 00000000000..c3a90e7c236 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies` Documentation + +The `resourceguardproxies` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +// 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-02-01/resourceguardproxies/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/client.go new file mode 100644 index 00000000000..ad46ba07081 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxies/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/id_vault.go new file mode 100644 index 00000000000..a4e4dcbe174 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/id_vault.go @@ -0,0 +1,125 @@ +package resourceguardproxies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/id_vault_test.go new file mode 100644 index 00000000000..61ba264e982 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/resourceguardproxies/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/method_get_autorest.go new file mode 100644 index 00000000000..d7c440b262d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxies/model_resourceguardoperationdetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/model_resourceguardoperationdetail.go new file mode 100644 index 00000000000..fedeee2c425 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxies/model_resourceguardproxybase.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/model_resourceguardproxybase.go new file mode 100644 index 00000000000..26938a5027c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxies/model_resourceguardproxybaseresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/model_resourceguardproxybaseresource.go new file mode 100644 index 00000000000..bc307c162c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxies/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/predicates.go new file mode 100644 index 00000000000..dca1b113f34 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxies/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/version.go new file mode 100644 index 00000000000..81c90d70b8b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxies/version.go @@ -0,0 +1,12 @@ +package resourceguardproxies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourceguardproxies/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/README.md new file mode 100644 index 00000000000..c954fb93d29 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/README.md @@ -0,0 +1,94 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy` Documentation + +The `resourceguardproxy` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupResourceGuardProxyValue") + +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", "vaultValue", "backupResourceGuardProxyValue") + +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", "vaultValue", "backupResourceGuardProxyValue") + +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", "vaultValue", "backupResourceGuardProxyValue") + +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-02-01/resourceguardproxy/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/client.go new file mode 100644 index 00000000000..d07fa6e5381 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/id_backupresourceguardproxy.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/id_backupresourceguardproxy.go new file mode 100644 index 00000000000..26c1adf66e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/id_backupresourceguardproxy.go @@ -0,0 +1,134 @@ +package resourceguardproxy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupResourceGuardProxies", "backupResourceGuardProxies", "backupResourceGuardProxies"), + resourceids.UserSpecifiedSegment("backupResourceGuardProxyName", "backupResourceGuardProxyValue"), + } +} + +// 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-02-01/resourceguardproxy/id_backupresourceguardproxy_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/id_backupresourceguardproxy_test.go new file mode 100644 index 00000000000..6ec2131c440 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupResourceGuardProxyValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupResourceGuardProxyName != "backupResourceGuardProxyValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupResourceGuardProxyName'", id.BackupResourceGuardProxyName, "backupResourceGuardProxyValue") + } +} + +func TestFormatBackupResourceGuardProxyID(t *testing.T) { + actual := NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupResourceGuardProxyName: "backupResourceGuardProxyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupResourceGuardProxyName: "backupResourceGuardProxyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue/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/vAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS/bAcKuPrEsOuRcEgUaRdPrOxYvAlUe", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupResourceGuardProxyName: "bAcKuPrEsOuRcEgUaRdPrOxYvAlUe", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS/bAcKuPrEsOuRcEgUaRdPrOxYvAlUe/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-02-01/resourceguardproxy/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/method_delete_autorest.go new file mode 100644 index 00000000000..5bc566a1459 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/method_get_autorest.go new file mode 100644 index 00000000000..34cbc308b05 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/method_put_autorest.go new file mode 100644 index 00000000000..251f699920c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/method_unlockdelete_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/method_unlockdelete_autorest.go new file mode 100644 index 00000000000..4ddf4864869 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/model_resourceguardoperationdetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_resourceguardoperationdetail.go new file mode 100644 index 00000000000..a211e1f34bb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/model_resourceguardproxybase.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_resourceguardproxybase.go new file mode 100644 index 00000000000..9e601e04d32 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/model_resourceguardproxybaseresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_resourceguardproxybaseresource.go new file mode 100644 index 00000000000..f68fdd803b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/model_unlockdeleterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_unlockdeleterequest.go new file mode 100644 index 00000000000..5ed0ee6ebfe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/model_unlockdeleteresponse.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/model_unlockdeleteresponse.go new file mode 100644 index 00000000000..6304a0fa5e6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/resourceguardproxy/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/version.go new file mode 100644 index 00000000000..bba68d5d402 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/resourceguardproxy/version.go @@ -0,0 +1,12 @@ +package resourceguardproxy + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourceguardproxy/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/restores/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/restores/README.md new file mode 100644 index 00000000000..310b3157a8c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/restores` Documentation + +The `restores` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +payload := restores.RestoreRequestResource{ + // ... +} + + +if err := client.TriggerThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/restores/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/client.go new file mode 100644 index 00000000000..3263d991a1e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/constants.go new file mode 100644 index 00000000000..2bbf6f4139c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/constants.go @@ -0,0 +1,272 @@ +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-02-01/restores/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/id_recoverypoint.go new file mode 100644 index 00000000000..cebd51bedb4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/id_recoverypoint.go @@ -0,0 +1,161 @@ +package restores + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// 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-02-01/restores/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/id_recoverypoint_test.go new file mode 100644 index 00000000000..443509d2e47 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue" + 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/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/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/vaultValue", + 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/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/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-02-01/restores/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/method_trigger_autorest.go new file mode 100644 index 00000000000..4a458fa582a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/method_trigger_autorest.go @@ -0,0 +1,79 @@ +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 +} + +// Trigger ... +func (c RestoresClient) Trigger(ctx context.Context, id RecoveryPointId, input RestoreRequestResource) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id, input) + 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) 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 RestoresClient) preparerForTrigger(ctx context.Context, id RecoveryPointId, input RestoreRequestResource) (*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/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-02-01/restores/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..731b4adc0f3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azurefilesharerestorerequest.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/restores/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..c18b9c4669b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/restores/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..880473a9a34 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadrestorerequest.go @@ -0,0 +1,49 @@ +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 +} + +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-02-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..fc66129d770 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..d84d86e2f28 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,51 @@ +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 +} + +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-02-01/restores/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..787926142bb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,49 @@ +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 +} + +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-02-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..4e9d922264a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/restores/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..f0fd8b50bca --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,53 @@ +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 +} + +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-02-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..3daee98175e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,54 @@ +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 +} + +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-02-01/restores/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..42aeefeffe9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,52 @@ +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 +} + +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-02-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..245a28b0788 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,53 @@ +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 +} + +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-02-01/restores/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_encryptiondetails.go new file mode 100644 index 00000000000..59b1b6b4b01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_extendedlocation.go new file mode 100644 index 00000000000..379c8d626ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..4480e70efa7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_iaasvmrestorerequest.go @@ -0,0 +1,65 @@ +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 +} + +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-02-01/restores/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..d905fc56e53 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,66 @@ +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 +} + +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-02-01/restores/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..a9c51c27edc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_identityinfo.go new file mode 100644 index 00000000000..54e5f53f23c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..73a3eba8ff1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorefilespecs.go new file mode 100644 index 00000000000..717dcbaffd2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorerequest.go new file mode 100644 index 00000000000..099b65bab20 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorerequest.go @@ -0,0 +1,149 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawRestoreRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorerequestresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorerequestresource.go new file mode 100644 index 00000000000..47ea43b2a9e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_restorerequestresource.go @@ -0,0 +1,50 @@ +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 { + type alias RestoreRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RestoreRequestResource: %+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-02-01/restores/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_securedvmdetails.go new file mode 100644 index 00000000000..f83115fc592 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..dcd5798e292 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..6a51b7654a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..c87d917d3d7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..a4aef071ffb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_targetrestoreinfo.go new file mode 100644 index 00000000000..84b61c24b37 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..af278e430c4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..0544cfe81fe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/restores/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/restores/version.go new file mode 100644 index 00000000000..f3c05e6a5ec --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/restores/version.go @@ -0,0 +1,12 @@ +package restores + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/restores/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/README.md new file mode 100644 index 00000000000..24d37032bc0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/securitypins` Documentation + +The `securitypins` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +payload := securitypins.SecurityPinBase{ + // ... +} + + +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-02-01/securitypins/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/client.go new file mode 100644 index 00000000000..117208a5554 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/securitypins/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/id_vault.go new file mode 100644 index 00000000000..8c7bd238c38 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/id_vault.go @@ -0,0 +1,125 @@ +package securitypins + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/id_vault_test.go new file mode 100644 index 00000000000..13faade3656 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/securitypins/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/method_get_autorest.go new file mode 100644 index 00000000000..34fe1e336f4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/method_get_autorest.go @@ -0,0 +1,70 @@ +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 +} + +// Get ... +func (c SecurityPINsClient) Get(ctx context.Context, id VaultId, input SecurityPinBase) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, input) + 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) (*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/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-02-01/securitypins/model_securitypinbase.go b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/model_securitypinbase.go new file mode 100644 index 00000000000..acc76db8d99 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/securitypins/model_tokeninformation.go b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/model_tokeninformation.go new file mode 100644 index 00000000000..cfebb48a56d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/securitypins/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/version.go new file mode 100644 index 00000000000..21824330edc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/securitypins/version.go @@ -0,0 +1,12 @@ +package securitypins + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/securitypins/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/README.md new file mode 100644 index 00000000000..ab436f86386 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers` Documentation + +The `softdeletedcontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +// 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-02-01/softdeletedcontainers/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/client.go new file mode 100644 index 00000000000..a671a0559b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/constants.go new file mode 100644 index 00000000000..66a7b8fc216 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/constants.go @@ -0,0 +1,330 @@ +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-02-01/softdeletedcontainers/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/id_vault.go new file mode 100644 index 00000000000..e74d30b7535 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/id_vault.go @@ -0,0 +1,125 @@ +package softdeletedcontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/id_vault_test.go new file mode 100644 index 00000000000..be6885444be --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go new file mode 100644 index 00000000000..412ffcc44a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..573efc50aa1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurebackupservercontainer.go @@ -0,0 +1,53 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureBackupServerContainer{} + +func (s AzureBackupServerContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerContainer: %+v", err) + } + decoded["containerType"] = "AzureBackupServerContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..1ffb8ed0e0d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,48 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMContainer{} + +func (s AzureIaaSClassicComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..24481ef7aeb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,48 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMContainer{} + +func (s AzureIaaSComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..e359f39f411 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSQLAGWorkloadContainerProtectionContainer{} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSQLAGWorkloadContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "SQLAGWorkLoadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..e45c918f9ff --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azuresqlcontainer.go @@ -0,0 +1,45 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSqlContainer{} + +func (s AzureSqlContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlContainer: %+v", err) + } + decoded["containerType"] = "AzureSqlContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..f0c84f07fa1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurestoragecontainer.go @@ -0,0 +1,50 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureStorageContainer{} + +func (s AzureStorageContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageContainer: %+v", err) + } + decoded["containerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..19bc1ebe0f0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureVMAppContainerProtectionContainer{} + +func (s AzureVMAppContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..e89bdafedc4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureworkloadcontainer.go @@ -0,0 +1,50 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainer{} + +func (s AzureWorkloadContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainer: %+v", err) + } + decoded["containerType"] = "AzureWorkloadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..141007ebdda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..367cba6804a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..3e35634654c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..349969c7db5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_dpmcontainer.go @@ -0,0 +1,53 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = DpmContainer{} + +func (s DpmContainer) MarshalJSON() ([]byte, error) { + type wrapper DpmContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmContainer: %+v", err) + } + decoded["containerType"] = "DPMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..c0f911a34b6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_errordetail.go new file mode 100644 index 00000000000..b76617c0e57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_genericcontainer.go new file mode 100644 index 00000000000..c5e6d8bd349 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_genericcontainer.go @@ -0,0 +1,47 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = GenericContainer{} + +func (s GenericContainer) MarshalJSON() ([]byte, error) { + type wrapper GenericContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericContainer: %+v", err) + } + decoded["containerType"] = "GenericContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..79e66b1ffda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..b8f3da1ebe1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_iaasvmcontainer.go @@ -0,0 +1,48 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = IaaSVMContainer{} + +func (s IaaSVMContainer) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMContainer: %+v", err) + } + decoded["containerType"] = "IaasVMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..c4d9f8360b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..5d9553ccad7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_mabcontainer.go new file mode 100644 index 00000000000..6a7fcdfdffa --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_mabcontainer.go @@ -0,0 +1,52 @@ +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"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = MabContainer{} + +func (s MabContainer) MarshalJSON() ([]byte, error) { + type wrapper MabContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabContainer: %+v", err) + } + decoded["containerType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..a5bc672fcf2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..8e91b126cc6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..46f032ed5da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_protectioncontainer.go @@ -0,0 +1,141 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionContainerImplementation(input []byte) (ProtectionContainer, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionContainer into map[string]interface: %+v", err) + } + + value, ok := temp["containerType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupServerContainer") { + var out AzureBackupServerContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAGWorkLoadContainer") { + var out AzureSQLAGWorkloadContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSqlContainer") { + var out AzureSqlContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainer") { + var out AzureWorkloadContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMContainer") { + var out DpmContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericContainer") { + var out GenericContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMContainer") { + var out IaaSVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out MabContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabContainer: %+v", err) + } + return out, nil + } + + out := RawProtectionContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..2d5ed02148a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_protectioncontainerresource.go @@ -0,0 +1,50 @@ +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 { + type alias ProtectionContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionContainerResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionContainerResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..ca519886a94 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/predicates.go new file mode 100644 index 00000000000..65cbf0427e6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/softdeletedcontainers/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/version.go new file mode 100644 index 00000000000..e2ca28b545f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/softdeletedcontainers/version.go @@ -0,0 +1,12 @@ +package softdeletedcontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/softdeletedcontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/README.md b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/README.md new file mode 100644 index 00000000000..d48dccf57d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation` Documentation + +The `validateoperation` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-02-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-02-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", "vaultValue") + +payload := validateoperation.ValidateOperationRequestResource{ + // ... +} + + +if err := client.TriggerThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/client.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/client.go new file mode 100644 index 00000000000..e729f452d88 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/constants.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/constants.go new file mode 100644 index 00000000000..1e9aaff03ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/constants.go @@ -0,0 +1,272 @@ +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-02-01/validateoperation/id_vault.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/id_vault.go new file mode 100644 index 00000000000..d167018dd5f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/id_vault.go @@ -0,0 +1,125 @@ +package validateoperation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + 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", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/id_vault_test.go new file mode 100644 index 00000000000..8cea883e88e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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", "vaultValue") + + 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 != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + 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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/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/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // 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/vAuLtVaLuE/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-02-01/validateoperation/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/method_trigger_autorest.go new file mode 100644 index 00000000000..1255fd9377e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..f7f995b0ccf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azurefilesharerestorerequest.go @@ -0,0 +1,46 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..0b71a891f3c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..6e1f1ed375c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadrestorerequest.go @@ -0,0 +1,49 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..640f9178791 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..81ab4ed9c52 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,51 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..bc1a6c4492c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,49 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..e5fce7d56ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,50 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..ef69ab25b0a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,53 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..5f50b178447 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,54 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..261aeb4550c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,52 @@ +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 +} + +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-02-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..540aad383ec --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,53 @@ +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 +} + +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-02-01/validateoperation/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_encryptiondetails.go new file mode 100644 index 00000000000..68be47387a8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_extendedlocation.go new file mode 100644 index 00000000000..608d19191a4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..b6ff82b3064 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_iaasvmrestorerequest.go @@ -0,0 +1,65 @@ +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 +} + +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-02-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..6ab30430699 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,66 @@ +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 +} + +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-02-01/validateoperation/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..d804db396e3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_identityinfo.go new file mode 100644 index 00000000000..71e633fc3ea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..9f5b85e6ad0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_restorefilespecs.go new file mode 100644 index 00000000000..f850cae1f62 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_restorerequest.go new file mode 100644 index 00000000000..f4c271d65e1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_restorerequest.go @@ -0,0 +1,149 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawRestoreRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_securedvmdetails.go new file mode 100644 index 00000000000..d6bbd38ddcc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..f9a96fc887b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..3d7ad759e25 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..32d155ab051 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..9185ea14d0c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_targetrestoreinfo.go new file mode 100644 index 00000000000..03ec88a3e93 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..572eae60d18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..b8d3bbe00a1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-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-02-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go new file mode 100644 index 00000000000..01dc3ab0f73 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateiaasvmrestoreoperationrequest.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 _ ValidateOperationRequest = ValidateIaasVMRestoreOperationRequest{} + +type ValidateIaasVMRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest +} + +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 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-02-01/validateoperation/model_validateoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateoperationrequest.go new file mode 100644 index 00000000000..1874b1156b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateoperationrequest.go @@ -0,0 +1,61 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawValidateOperationRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateoperationrequestresource.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateoperationrequestresource.go new file mode 100644 index 00000000000..d86e4783597 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validateoperationrequestresource.go @@ -0,0 +1,40 @@ +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 { + type alias ValidateOperationRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ValidateOperationRequestResource: %+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-02-01/validateoperation/model_validaterestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validaterestoreoperationrequest.go new file mode 100644 index 00000000000..16aa0307fac --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/model_validaterestoreoperationrequest.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 _ ValidateOperationRequest = ValidateRestoreOperationRequest{} + +type ValidateRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest +} + +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 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-02-01/validateoperation/version.go b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/version.go new file mode 100644 index 00000000000..45d1c10a727 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-02-01/validateoperation/version.go @@ -0,0 +1,12 @@ +package validateoperation + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/validateoperation/%s", defaultApiVersion) +}