From 48a1c3a0b5ba15f248fb7e3ae8992ca69828359f Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Wed, 7 Feb 2024 13:32:32 +0000 Subject: [PATCH] Updating based on ac70f8df --- .../2023-08-01/client.go | 271 ++++++ .../migrationrecoverypoints/README.md | 53 ++ .../migrationrecoverypoints/client.go | 26 + .../migrationrecoverypoints/constants.go | 54 ++ .../id_migrationrecoverypoint.go | 161 ++++ .../id_migrationrecoverypoint_test.go | 462 ++++++++++ .../id_replicationmigrationitem.go | 152 ++++ .../id_replicationmigrationitem_test.go | 417 +++++++++ .../migrationrecoverypoints/method_get.go | 51 ++ .../method_listbyreplicationmigrationitems.go | 91 ++ .../model_migrationrecoverypoint.go | 12 + .../model_migrationrecoverypointproperties.go | 27 + .../migrationrecoverypoints/predicates.go | 32 + .../migrationrecoverypoints/version.go | 12 + .../2023-08-01/operations/README.md | 38 + .../2023-08-01/operations/client.go | 26 + .../2023-08-01/operations/method_list.go | 92 ++ .../2023-08-01/operations/model_display.go | 11 + .../operations/model_operationsdiscovery.go | 11 + .../2023-08-01/operations/predicates.go | 27 + .../2023-08-01/operations/version.go | 12 + .../2023-08-01/recoverypoints/README.md | 53 ++ .../2023-08-01/recoverypoints/client.go | 26 + .../2023-08-01/recoverypoints/constants.go | 51 ++ .../recoverypoints/id_recoverypoint.go | 161 ++++ .../recoverypoints/id_recoverypoint_test.go | 462 ++++++++++ .../id_replicationprotecteditem.go | 152 ++++ .../id_replicationprotecteditem_test.go | 417 +++++++++ .../2023-08-01/recoverypoints/method_get.go | 51 ++ .../method_listbyreplicationprotecteditems.go | 91 ++ .../model_a2arecoverypointdetails.go | 42 + ...model_inmageazurev2recoverypointdetails.go | 41 + .../model_inmagercmrecoverypointdetails.go | 41 + ...el_providerspecificrecoverypointdetails.go | 69 ++ .../recoverypoints/model_recoverypoint.go | 12 + .../model_recoverypointproperties.go | 57 ++ .../2023-08-01/recoverypoints/predicates.go | 32 + .../2023-08-01/recoverypoints/version.go | 12 + .../replicationalertsettings/README.md | 74 ++ .../replicationalertsettings/client.go | 26 + .../id_replicationalertsetting.go | 134 +++ .../id_replicationalertsetting_test.go | 327 +++++++ .../replicationalertsettings/id_vault.go | 125 +++ .../replicationalertsettings/id_vault_test.go | 282 ++++++ .../replicationalertsettings/method_create.go | 55 ++ .../replicationalertsettings/method_get.go | 51 ++ .../replicationalertsettings/method_list.go | 91 ++ .../replicationalertsettings/model_alert.go | 12 + .../model_alertproperties.go | 10 + .../model_configurealertrequest.go | 8 + .../model_configurealertrequestproperties.go | 10 + .../replicationalertsettings/predicates.go | 32 + .../replicationalertsettings/version.go | 12 + .../replicationappliances/README.md | 37 + .../replicationappliances/client.go | 26 + .../replicationappliances/constants.go | 145 +++ .../replicationappliances/id_vault.go | 125 +++ .../replicationappliances/id_vault_test.go | 282 ++++++ .../replicationappliances/method_list.go | 119 +++ .../model_appliancespecificdetails.go | 53 ++ .../replicationappliances/model_dradetails.go | 34 + .../model_healtherror.go | 40 + .../model_inmagercmappliancedetails.go | 18 + ...model_inmagercmappliancespecificdetails.go | 41 + ...abricswitchproviderblockingerrordetails.go | 13 + .../model_innerhealtherror.go | 39 + .../model_marsagentdetails.go | 34 + .../model_processserverdetails.go | 54 ++ .../model_pushinstallerdetails.go | 34 + .../model_rcmproxydetails.go | 35 + .../model_replicationagentdetails.go | 34 + .../model_replicationappliance.go | 8 + .../model_replicationapplianceproperties.go | 32 + .../model_reprotectagentdetails.go | 50 ++ .../replicationappliances/predicates.go | 12 + .../replicationappliances/version.go | 12 + .../replicationeligibilityresults/README.md | 52 ++ .../replicationeligibilityresults/client.go | 26 + .../id_virtualmachine.go | 125 +++ .../id_virtualmachine_test.go | 282 ++++++ .../method_get.go | 52 ++ .../method_list.go | 52 ++ .../model_replicationeligibilityresults.go | 11 + ...replicationeligibilityresultscollection.go | 8 + ..._replicationeligibilityresultserrorinfo.go | 12 + ...replicationeligibilityresultsproperties.go | 9 + .../replicationeligibilityresults/version.go | 12 + .../2023-08-01/replicationevents/README.md | 53 ++ .../2023-08-01/replicationevents/client.go | 26 + .../2023-08-01/replicationevents/constants.go | 51 ++ .../replicationevents/id_replicationevent.go | 134 +++ .../id_replicationevent_test.go | 327 +++++++ .../2023-08-01/replicationevents/id_vault.go | 125 +++ .../replicationevents/id_vault_test.go | 282 ++++++ .../replicationevents/method_get.go | 51 ++ .../replicationevents/method_list.go | 119 +++ .../model_a2aeventdetails.go | 46 + .../replicationevents/model_event.go | 12 + .../model_eventproperties.go | 80 ++ .../model_eventproviderspecificdetails.go | 117 +++ .../model_eventspecificdetails.go | 53 ++ .../replicationevents/model_healtherror.go | 40 + .../model_hypervreplica2012eventdetails.go | 44 + .../model_hypervreplica2012r2eventdetails.go | 44 + .../model_hypervreplicaazureeventdetails.go | 43 + .../model_hypervreplicabaseeventdetails.go | 44 + .../model_inmageazurev2eventdetails.go | 47 + .../model_inmagercmeventdetails.go | 48 + .../model_inmagercmfailbackeventdetails.go | 45 + .../model_innerhealtherror.go | 39 + .../model_jobstatuseventdetails.go | 44 + .../model_vmwarecbteventdetails.go | 41 + .../replicationevents/predicates.go | 32 + .../2023-08-01/replicationevents/version.go | 12 + .../2023-08-01/replicationfabrics/README.md | 164 ++++ .../2023-08-01/replicationfabrics/client.go | 26 + .../replicationfabrics/constants.go | 195 ++++ .../id_replicationfabric.go | 134 +++ .../id_replicationfabric_test.go | 327 +++++++ .../2023-08-01/replicationfabrics/id_vault.go | 125 +++ .../replicationfabrics/id_vault_test.go | 282 ++++++ .../method_checkconsistency.go | 71 ++ .../replicationfabrics/method_create.go | 75 ++ .../replicationfabrics/method_delete.go | 70 ++ .../replicationfabrics/method_get.go | 80 ++ .../replicationfabrics/method_list.go | 91 ++ .../replicationfabrics/method_migratetoaad.go | 70 ++ .../replicationfabrics/method_purge.go | 70 ++ .../method_reassociategateway.go | 75 ++ .../replicationfabrics/method_removeinfra.go | 69 ++ .../method_renewcertificate.go | 75 ++ .../model_a2aextendedlocationdetails.go | 13 + .../model_a2afabricspecificlocationdetails.go | 23 + .../model_a2azonedetails.go | 9 + .../replicationfabrics/model_agentdetails.go | 12 + .../model_agentdiskdetails.go | 12 + .../model_azurefabriccreationinput.go | 41 + .../model_azurefabricspecificdetails.go | 45 + .../replicationfabrics/model_datastore.go | 12 + .../replicationfabrics/model_dradetails.go | 34 + .../model_encryptiondetails.go | 28 + .../replicationfabrics/model_fabric.go | 12 + .../model_fabriccreationinput.go | 8 + .../model_fabriccreationinputproperties.go | 32 + .../model_fabricproperties.go | 52 ++ .../model_fabricspecificcreationinput.go | 69 ++ .../model_fabricspecificdetails.go | 93 ++ .../model_failoverprocessserverrequest.go | 8 + ..._failoverprocessserverrequestproperties.go | 12 + .../replicationfabrics/model_healtherror.go | 40 + .../model_hypervhostdetails.go | 10 + .../model_hypervsitedetails.go | 41 + .../model_identityproviderdetails.go | 12 + .../model_identityproviderinput.go | 12 + ...abricswitchproviderblockingerrordetails.go | 13 + .../model_inmagercmfabriccreationinput.go | 43 + .../model_inmagercmfabricspecificdetails.go | 56 ++ .../model_innerhealtherror.go | 39 + .../model_marsagentdetails.go | 34 + .../model_mastertargetserver.go | 67 ++ .../model_mobilityserviceupdate.go | 10 + .../replicationfabrics/model_processserver.go | 97 ++ .../model_processserverdetails.go | 54 ++ .../model_pushinstallerdetails.go | 34 + .../model_rcmproxydetails.go | 35 + .../model_renewcertificateinput.go | 8 + .../model_renewcertificateinputproperties.go | 8 + .../model_replicationagentdetails.go | 34 + .../model_reprotectagentdetails.go | 50 ++ .../model_retentionvolume.go | 11 + .../replicationfabrics/model_runasaccount.go | 9 + .../model_versiondetails.go | 28 + .../replicationfabrics/model_vmmdetails.go | 40 + .../replicationfabrics/model_vmwaredetails.go | 73 ++ .../model_vmwarev2fabriccreationinput.go | 43 + .../model_vmwarev2fabricspecificdetails.go | 47 + .../replicationfabrics/predicates.go | 32 + .../2023-08-01/replicationfabrics/version.go | 12 + .../2023-08-01/replicationjobs/README.md | 111 +++ .../2023-08-01/replicationjobs/client.go | 26 + .../2023-08-01/replicationjobs/constants.go | 54 ++ .../replicationjobs/id_replicationjob.go | 134 +++ .../replicationjobs/id_replicationjob_test.go | 327 +++++++ .../2023-08-01/replicationjobs/id_vault.go | 125 +++ .../replicationjobs/id_vault_test.go | 282 ++++++ .../replicationjobs/method_cancel.go | 71 ++ .../replicationjobs/method_export.go | 75 ++ .../2023-08-01/replicationjobs/method_get.go | 51 ++ .../2023-08-01/replicationjobs/method_list.go | 119 +++ .../replicationjobs/method_restart.go | 71 ++ .../replicationjobs/method_resume.go | 75 ++ .../replicationjobs/model_asrjobdetails.go | 41 + .../replicationjobs/model_asrtask.go | 94 ++ .../model_automationrunbooktaskdetails.go | 49 ++ .../model_consistencychecktaskdetails.go | 41 + .../replicationjobs/model_exportjobdetails.go | 43 + ...model_fabricreplicationgrouptaskdetails.go | 43 + .../model_failoverjobdetails.go | 42 + ...failoverreplicationprotecteditemdetails.go | 34 + .../replicationjobs/model_grouptaskdetails.go | 61 ++ .../model_inconsistentvmdetails.go | 11 + .../model_inlineworkflowtaskdetails.go | 42 + .../2023-08-01/replicationjobs/model_job.go | 12 + .../replicationjobs/model_jobdetails.go | 85 ++ .../replicationjobs/model_jobentity.go | 13 + .../replicationjobs/model_joberrordetails.go | 30 + .../replicationjobs/model_jobproperties.go | 91 ++ .../model_jobqueryparameter.go | 15 + .../replicationjobs/model_jobtaskdetails.go | 41 + .../model_manualactiontaskdetails.go | 43 + .../replicationjobs/model_providererror.go | 12 + .../model_recoveryplangrouptaskdetails.go | 44 + ...el_recoveryplanshutdowngrouptaskdetails.go | 43 + .../replicationjobs/model_resumejobparams.go | 8 + .../model_resumejobparamsproperties.go | 8 + .../model_scriptactiontaskdetails.go | 44 + .../replicationjobs/model_serviceerror.go | 12 + .../model_switchprotectionjobdetails.go | 42 + .../replicationjobs/model_tasktypedetails.go | 93 ++ .../model_testfailoverjobdetails.go | 47 + .../model_virtualmachinetaskdetails.go | 43 + .../model_vmnicupdatestaskdetails.go | 43 + .../2023-08-01/replicationjobs/predicates.go | 32 + .../2023-08-01/replicationjobs/version.go | 12 + .../replicationlogicalnetworks/README.md | 53 ++ .../replicationlogicalnetworks/client.go | 26 + .../id_replicationfabric.go | 134 +++ .../id_replicationfabric_test.go | 327 +++++++ .../id_replicationlogicalnetwork.go | 143 +++ .../id_replicationlogicalnetwork_test.go | 372 ++++++++ .../replicationlogicalnetworks/method_get.go | 51 ++ .../method_listbyreplicationfabrics.go | 91 ++ .../model_logicalnetwork.go | 12 + .../model_logicalnetworkproperties.go | 11 + .../replicationlogicalnetworks/predicates.go | 32 + .../replicationlogicalnetworks/version.go | 12 + .../replicationmigrationitems/README.md | 218 +++++ .../replicationmigrationitems/client.go | 26 + .../replicationmigrationitems/constants.go | 560 ++++++++++++ .../id_replicationmigrationitem.go | 152 ++++ .../id_replicationmigrationitem_test.go | 417 +++++++++ .../id_replicationprotectioncontainer.go | 143 +++ .../id_replicationprotectioncontainer_test.go | 372 ++++++++ .../replicationmigrationitems/id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_create.go | 75 ++ .../method_delete.go | 98 +++ .../replicationmigrationitems/method_get.go | 51 ++ .../replicationmigrationitems/method_list.go | 127 +++ ...d_listbyreplicationprotectioncontainers.go | 127 +++ .../method_migrate.go | 75 ++ .../method_pausereplication.go | 75 ++ .../method_resumereplication.go | 75 ++ .../method_resync.go | 75 ++ .../method_testmigrate.go | 75 ++ .../method_testmigratecleanup.go | 75 ++ .../method_update.go | 75 ++ .../model_appliancemonitoringdetails.go | 13 + .../model_applianceresourcedetails.go | 11 + .../model_criticaljobhistorydetails.go | 29 + .../model_currentjobdetails.go | 28 + .../model_datastoreutilizationdetails.go | 10 + .../model_enablemigrationinput.go | 8 + .../model_enablemigrationinputproperties.go | 40 + ...el_enablemigrationproviderspecificinput.go | 53 ++ .../model_gatewayoperationdetails.go | 15 + .../model_healtherror.go | 40 + .../model_innerhealtherror.go | 39 + .../model_migrateinput.go | 8 + .../model_migrateinputproperties.go | 32 + .../model_migrateproviderspecificinput.go | 53 ++ .../model_migrationitem.go | 12 + .../model_migrationitemproperties.go | 103 +++ ...model_migrationproviderspecificsettings.go | 53 ++ .../model_pausereplicationinput.go | 8 + .../model_pausereplicationinputproperties.go | 8 + .../model_resumereplicationinput.go | 8 + .../model_resumereplicationinputproperties.go | 32 + ..._resumereplicationproviderspecificinput.go | 53 ++ .../model_resyncinput.go | 8 + .../model_resyncinputproperties.go | 32 + .../model_resyncproviderspecificinput.go | 53 ++ .../model_testmigratecleanupinput.go | 8 + ...model_testmigratecleanupinputproperties.go | 8 + .../model_testmigrateinput.go | 8 + .../model_testmigrateinputproperties.go | 32 + .../model_testmigrateproviderspecificinput.go | 53 ++ .../model_updatemigrationiteminput.go | 8 + ...odel_updatemigrationiteminputproperties.go | 32 + ...pdatemigrationitemproviderspecificinput.go | 53 ++ .../model_vmwarecbtdiskinput.go | 13 + .../model_vmwarecbtenablemigrationinput.go | 65 ++ .../model_vmwarecbtmigrateinput.go | 42 + .../model_vmwarecbtmigrationdetails.go | 88 ++ .../model_vmwarecbtnicdetails.go | 21 + .../model_vmwarecbtnicinput.go | 15 + .../model_vmwarecbtprotecteddiskdetails.go | 22 + .../model_vmwarecbtresumereplicationinput.go | 41 + .../model_vmwarecbtresyncinput.go | 41 + ...odel_vmwarecbtsecurityprofileproperties.go | 12 + .../model_vmwarecbttestmigrateinput.go | 44 + .../model_vmwarecbtupdatediskinput.go | 10 + ...model_vmwarecbtupdatemigrationiteminput.go | 57 ++ .../replicationmigrationitems/predicates.go | 32 + .../replicationmigrationitems/version.go | 12 + .../replicationnetworkmappings/README.md | 116 +++ .../replicationnetworkmappings/client.go | 26 + .../id_replicationnetwork.go | 143 +++ .../id_replicationnetwork_test.go | 372 ++++++++ .../id_replicationnetworkmapping.go | 152 ++++ .../id_replicationnetworkmapping_test.go | 417 +++++++++ .../replicationnetworkmappings/id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_create.go | 75 ++ .../method_delete.go | 70 ++ .../replicationnetworkmappings/method_get.go | 51 ++ .../replicationnetworkmappings/method_list.go | 91 ++ .../method_listbyreplicationnetworks.go | 91 ++ .../method_update.go | 75 ++ ...l_azuretoazurecreatenetworkmappinginput.go | 41 + ...odel_azuretoazurenetworkmappingsettings.go | 42 + ...l_azuretoazureupdatenetworkmappinginput.go | 41 + .../model_createnetworkmappinginput.go | 8 + ...del_createnetworkmappinginputproperties.go | 42 + ...fabricspecificcreatenetworkmappinginput.go | 69 ++ ...fabricspecificupdatenetworkmappinginput.go | 69 ++ .../model_networkmapping.go | 12 + ...el_networkmappingfabricspecificsettings.go | 69 ++ .../model_networkmappingproperties.go | 54 ++ .../model_updatenetworkmappinginput.go | 8 + ...del_updatenetworkmappinginputproperties.go | 42 + ...del_vmmtoazurecreatenetworkmappinginput.go | 40 + .../model_vmmtoazurenetworkmappingsettings.go | 40 + ...del_vmmtoazureupdatenetworkmappinginput.go | 40 + ...model_vmmtovmmcreatenetworkmappinginput.go | 40 + .../model_vmmtovmmnetworkmappingsettings.go | 40 + ...model_vmmtovmmupdatenetworkmappinginput.go | 40 + .../replicationnetworkmappings/predicates.go | 32 + .../replicationnetworkmappings/version.go | 12 + .../2023-08-01/replicationnetworks/README.md | 70 ++ .../2023-08-01/replicationnetworks/client.go | 26 + .../id_replicationfabric.go | 134 +++ .../id_replicationfabric_test.go | 327 +++++++ .../id_replicationnetwork.go | 143 +++ .../id_replicationnetwork_test.go | 372 ++++++++ .../replicationnetworks/id_vault.go | 125 +++ .../replicationnetworks/id_vault_test.go | 282 ++++++ .../replicationnetworks/method_get.go | 51 ++ .../replicationnetworks/method_list.go | 91 ++ .../method_listbyreplicationfabrics.go | 91 ++ .../replicationnetworks/model_network.go | 12 + .../model_networkproperties.go | 11 + .../replicationnetworks/model_subnet.go | 10 + .../replicationnetworks/predicates.go | 32 + .../2023-08-01/replicationnetworks/version.go | 12 + .../2023-08-01/replicationpolicies/README.md | 99 +++ .../2023-08-01/replicationpolicies/client.go | 26 + .../replicationpolicies/constants.go | 51 ++ .../id_replicationpolicy.go | 134 +++ .../id_replicationpolicy_test.go | 327 +++++++ .../replicationpolicies/id_vault.go | 125 +++ .../replicationpolicies/id_vault_test.go | 282 ++++++ .../replicationpolicies/method_create.go | 75 ++ .../replicationpolicies/method_delete.go | 70 ++ .../replicationpolicies/method_get.go | 51 ++ .../replicationpolicies/method_list.go | 91 ++ .../replicationpolicies/method_update.go | 75 ++ ...rossclustermigrationpolicycreationinput.go | 40 + .../model_a2apolicycreationinput.go | 44 + .../model_a2apolicydetails.go | 45 + .../model_createpolicyinput.go | 8 + .../model_createpolicyinputproperties.go | 32 + .../model_hypervreplicaazurepolicydetails.go | 46 + .../model_hypervreplicaazurepolicyinput.go | 45 + .../model_hypervreplicabasepolicydetails.go | 50 ++ .../model_hypervreplicabluepolicydetails.go | 51 ++ .../model_hypervreplicabluepolicyinput.go | 51 ++ .../model_hypervreplicapolicydetails.go | 50 ++ .../model_hypervreplicapolicyinput.go | 50 ++ .../model_inmageazurev2policydetails.go | 45 + .../model_inmageazurev2policyinput.go | 45 + .../model_inmagebasepolicydetails.go | 44 + .../model_inmagepolicydetails.go | 44 + .../model_inmagepolicyinput.go | 44 + ...el_inmagercmfailbackpolicycreationinput.go | 42 + .../model_inmagercmfailbackpolicydetails.go | 42 + .../model_inmagercmpolicycreationinput.go | 44 + .../model_inmagercmpolicydetails.go | 44 + .../replicationpolicies/model_policy.go | 12 + .../model_policyproperties.go | 40 + .../model_policyproviderspecificdetails.go | 133 +++ .../model_policyproviderspecificinput.go | 117 +++ .../model_updatepolicyinput.go | 8 + .../model_updatepolicyinputproperties.go | 32 + .../model_vmwarecbtpolicycreationinput.go | 43 + .../model_vmwarecbtpolicydetails.go | 43 + .../replicationpolicies/predicates.go | 32 + .../2023-08-01/replicationpolicies/version.go | 12 + .../replicationprotectableitems/README.md | 53 ++ .../replicationprotectableitems/client.go | 26 + .../replicationprotectableitems/constants.go | 95 ++ .../id_replicationprotectableitem.go | 152 ++++ .../id_replicationprotectableitem_test.go | 417 +++++++++ .../id_replicationprotectioncontainer.go | 143 +++ .../id_replicationprotectioncontainer_test.go | 372 ++++++++ .../replicationprotectableitems/method_get.go | 51 ++ ...d_listbyreplicationprotectioncontainers.go | 123 +++ .../model_configurationsettings.go | 69 ++ .../model_diskdetails.go | 11 + .../model_diskvolumedetails.go | 9 + .../model_healtherror.go | 40 + .../model_hypervvirtualmachinedetails.go | 48 + .../model_inmagediskdetails.go | 13 + .../model_innerhealtherror.go | 39 + .../model_osdetails.go | 13 + .../model_protectableitem.go | 12 + .../model_protectableitemproperties.go | 50 ++ .../model_replicationgroupdetails.go | 40 + .../model_vmmvirtualmachinedetails.go | 48 + .../model_vmwarevirtualmachinedetails.go | 50 ++ .../replicationprotectableitems/predicates.go | 32 + .../replicationprotectableitems/version.go | 12 + .../replicationprotecteditems/README.md | 373 ++++++++ .../replicationprotecteditems/client.go | 26 + .../replicationprotecteditems/constants.go | 832 ++++++++++++++++++ .../id_replicationprotecteditem.go | 152 ++++ .../id_replicationprotecteditem_test.go | 417 +++++++++ .../id_replicationprotectioncontainer.go | 143 +++ .../id_replicationprotectioncontainer_test.go | 372 ++++++++ .../replicationprotecteditems/id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_adddisks.go | 75 ++ .../method_applyrecoverypoint.go | 75 ++ .../method_create.go | 75 ++ .../method_delete.go | 74 ++ .../method_failovercancel.go | 71 ++ .../method_failovercommit.go | 71 ++ .../replicationprotecteditems/method_get.go | 51 ++ .../replicationprotecteditems/method_list.go | 123 +++ ...d_listbyreplicationprotectioncontainers.go | 91 ++ .../method_plannedfailover.go | 75 ++ .../replicationprotecteditems/method_purge.go | 70 ++ .../method_removedisks.go | 75 ++ .../method_repairreplication.go | 71 ++ .../method_reprotect.go | 75 ++ .../method_resolvehealtherrors.go | 75 ++ .../method_switchprovider.go | 75 ++ .../method_testfailover.go | 75 ++ .../method_testfailovercleanup.go | 75 ++ .../method_unplannedfailover.go | 75 ++ .../method_update.go | 75 ++ .../method_updateappliance.go | 75 ++ .../method_updatemobilityservice.go | 75 ++ .../model_a2aadddisksinput.go | 42 + .../model_a2aapplyrecoverypointinput.go | 40 + ...clustermigrationapplyrecoverypointinput.go | 40 + ...ssclustermigrationenableprotectioninput.go | 42 + ...crossclustermigrationreplicationdetails.go | 46 + .../model_a2aenableprotectioninput.go | 61 ++ .../model_a2aprotecteddiskdetails.go | 30 + .../model_a2aprotectedmanageddiskdetails.go | 35 + .../model_a2aremovedisksinput.go | 42 + .../model_a2areplicationdetails.go | 96 ++ .../model_a2areprotectinput.go | 46 + .../model_a2atestfailoverinput.go | 42 + .../model_a2aunplannedfailoverinput.go | 42 + .../model_a2aunprotecteddiskdetails.go | 9 + ..._a2aupdatereplicationprotectediteminput.go | 49 ++ .../model_a2avmdiskinputdetails.go | 10 + .../model_a2avmmanageddiskinputdetails.go | 14 + .../model_a2avmmanageddiskupdatedetails.go | 13 + .../model_adddisksinput.go | 8 + .../model_adddisksinputproperties.go | 32 + .../model_adddisksproviderspecificinput.go | 53 ++ .../model_applyrecoverypointinput.go | 8 + ...model_applyrecoverypointinputproperties.go | 40 + ...applyrecoverypointproviderspecificinput.go | 85 ++ ...model_azuretoazurevmsyncedconfigdetails.go | 9 + .../model_azurevmdiskdetails.go | 17 + .../model_currentscenariodetails.go | 28 + .../model_disableprotectioninput.go | 8 + .../model_disableprotectioninputproperties.go | 40 + ..._disableprotectionproviderspecificinput.go | 53 ++ .../model_diskdetails.go | 11 + .../model_diskencryptioninfo.go | 9 + .../model_diskencryptionkeyinfo.go | 9 + .../model_enableprotectioninput.go | 8 + .../model_enableprotectioninputproperties.go | 42 + ...l_enableprotectionproviderspecificinput.go | 93 ++ .../model_healtherror.go | 40 + ...pervreplicaazureapplyrecoverypointinput.go | 42 + ...odel_hypervreplicaazurediskinputdetails.go | 11 + ...hypervreplicaazureenableprotectioninput.go | 68 ++ ...hypervreplicaazurefailbackproviderinput.go | 43 + ...el_hypervreplicaazuremanageddiskdetails.go | 11 + ...eplicaazureplannedfailoverproviderinput.go | 44 + ...el_hypervreplicaazurereplicationdetails.go | 74 ++ .../model_hypervreplicaazurereprotectinput.go | 46 + ...del_hypervreplicaazuretestfailoverinput.go | 44 + ...ypervreplicaazureunplannedfailoverinput.go | 43 + ...zureupdatereplicationprotectediteminput.go | 51 ++ ...del_hypervreplicabasereplicationdetails.go | 47 + ...del_hypervreplicabluereplicationdetails.go | 47 + .../model_hypervreplicareplicationdetails.go | 47 + .../model_initialreplicationdetails.go | 9 + .../model_inmageagentdetails.go | 29 + ...el_inmageazurev2applyrecoverypointinput.go | 40 + .../model_inmageazurev2diskinputdetails.go | 11 + ...odel_inmageazurev2enableprotectioninput.go | 66 ++ .../model_inmageazurev2manageddiskdetails.go | 12 + ...model_inmageazurev2protecteddiskdetails.go | 72 ++ .../model_inmageazurev2replicationdetails.go | 110 +++ .../model_inmageazurev2reprotectinput.go | 47 + ...urev2switchproviderblockingerrordetails.go | 13 + ...odel_inmageazurev2switchproviderdetails.go | 11 + ...nmageazurev2switchproviderproviderinput.go | 43 + .../model_inmageazurev2testfailoverinput.go | 42 + ...del_inmageazurev2unplannedfailoverinput.go | 42 + ...rev2updatereplicationprotectediteminput.go | 50 ++ ...edisableprotectionproviderspecificinput.go | 41 + .../model_inmagediskexclusioninput.go | 9 + ...del_inmagedisksignatureexclusionoptions.go | 8 + .../model_inmageenableprotectioninput.go | 50 ++ .../model_inmageprotecteddiskdetails.go | 71 ++ ...magercmagentupgradeblockingerrordetails.go | 13 + .../model_inmagercmapplyrecoverypointinput.go | 41 + ...l_inmagercmdiscoveredprotectedvmdetails.go | 61 ++ .../model_inmagercmdiskinput.go | 11 + .../model_inmagercmdisksdefaultinput.go | 10 + .../model_inmagercmenableprotectioninput.go | 58 ++ ...rcmfailbackdiscoveredprotectedvmdetails.go | 61 ++ ...l_inmagercmfailbackmobilityagentdetails.go | 58 ++ .../model_inmagercmfailbacknicdetails.go | 11 + ...rcmfailbackplannedfailoverproviderinput.go | 41 + ...l_inmagercmfailbackprotecteddiskdetails.go | 36 + ...del_inmagercmfailbackreplicationdetails.go | 69 ++ .../model_inmagercmfailbackreprotectinput.go | 43 + .../model_inmagercmfailbacksyncdetails.go | 15 + ...l_inmagercmlastagentupgradeerrordetails.go | 13 + .../model_inmagercmmobilityagentdetails.go | 59 ++ .../model_inmagercmnicdetails.go | 20 + .../model_inmagercmnicinput.go | 14 + .../model_inmagercmprotecteddiskdetails.go | 22 + .../model_inmagercmreplicationdetails.go | 92 ++ .../model_inmagercmreprotectinput.go | 44 + .../model_inmagercmsyncdetails.go | 15 + .../model_inmagercmtestfailoverinput.go | 42 + .../model_inmagercmunplannedfailoverinput.go | 42 + ...plianceforreplicationprotectediteminput.go | 41 + ...ercmupdatereplicationprotectediteminput.go | 51 ++ .../model_inmagereplicationdetails.go | 80 ++ .../model_inmagereprotectinput.go | 48 + .../model_inmagetestfailoverinput.go | 42 + .../model_inmageunplannedfailoverinput.go | 42 + .../model_inmagevolumeexclusionoptions.go | 9 + .../model_innerhealtherror.go | 39 + .../model_inputendpoint.go | 11 + .../model_ipconfigdetails.go | 22 + .../model_ipconfiginputdetails.go | 18 + .../model_keyencryptionkeyinfo.go | 9 + .../model_osdetails.go | 13 + .../model_osdiskdetails.go | 10 + .../model_osupgradesupportedversions.go | 9 + .../model_plannedfailoverinput.go | 8 + .../model_plannedfailoverinputproperties.go | 40 + ...edfailoverproviderspecificfailoverinput.go | 69 ++ .../model_removedisksinput.go | 8 + .../model_removedisksinputproperties.go | 32 + .../model_removedisksproviderspecificinput.go | 53 ++ .../model_replicationprotecteditem.go | 12 + ...odel_replicationprotecteditemproperties.go | 123 +++ ...del_replicationproviderspecificsettings.go | 125 +++ .../model_resolvehealtherror.go | 8 + .../model_resolvehealthinput.go | 8 + .../model_resolvehealthinputproperties.go | 8 + .../model_reversereplicationinput.go | 8 + ...model_reversereplicationinputproperties.go | 40 + ...reversereplicationproviderspecificinput.go | 93 ++ .../model_switchproviderinput.go | 8 + .../model_switchproviderinputproperties.go | 40 + ...del_switchproviderproviderspecificinput.go | 53 ++ .../model_testfailovercleanupinput.go | 8 + ...odel_testfailovercleanupinputproperties.go | 8 + .../model_testfailoverinput.go | 8 + .../model_testfailoverinputproperties.go | 44 + ...model_testfailoverproviderspecificinput.go | 85 ++ .../model_unplannedfailoverinput.go | 8 + .../model_unplannedfailoverinputproperties.go | 42 + ..._unplannedfailoverproviderspecificinput.go | 85 ++ ...plianceforreplicationprotectediteminput.go | 8 + ...replicationprotectediteminputproperties.go | 40 + ...ationprotecteditemproviderspecificinput.go | 53 ++ .../model_updatediskinput.go | 9 + .../model_updatemobilityservicerequest.go | 8 + ..._updatemobilityservicerequestproperties.go | 8 + ...del_updatereplicationprotectediteminput.go | 8 + ...replicationprotectediteminputproperties.go | 56 ++ ...tereplicationprotecteditemproviderinput.go | 77 ++ .../model_vmnicdetails.go | 26 + .../model_vmnicinputdetails.go | 21 + .../replicationprotecteditems/predicates.go | 32 + .../replicationprotecteditems/version.go | 12 + .../README.md | 133 +++ .../client.go | 26 + .../constants.go | 133 +++ .../id_replicationprotectioncontainer.go | 143 +++ .../id_replicationprotectioncontainer_test.go | 372 ++++++++ ...d_replicationprotectioncontainermapping.go | 152 ++++ ...licationprotectioncontainermapping_test.go | 417 +++++++++ .../id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_create.go | 75 ++ .../method_delete.go | 74 ++ .../method_get.go | 51 ++ .../method_list.go | 91 ++ ...d_listbyreplicationprotectioncontainers.go | 91 ++ .../method_purge.go | 70 ++ .../method_update.go | 75 ++ .../model_a2acontainermappinginput.go | 43 + ...el_a2aprotectioncontainermappingdetails.go | 45 + .../model_a2aupdatecontainermappinginput.go | 43 + ...l_createprotectioncontainermappinginput.go | 8 + ...otectioncontainermappinginputproperties.go | 42 + .../model_healtherror.go | 40 + ...agercmprotectioncontainermappingdetails.go | 41 + ...el_inmagercmupdatecontainermappinginput.go | 41 + .../model_innerhealtherror.go | 39 + .../model_protectioncontainermapping.go | 12 + ...el_protectioncontainermappingproperties.go | 58 ++ ...containermappingproviderspecificdetails.go | 69 ++ ...l_removeprotectioncontainermappinginput.go | 8 + ...otectioncontainermappinginputproperties.go | 8 + ...licationprovidercontainerunmappinginput.go | 8 + ...onproviderspecificcontainermappinginput.go | 61 ++ ...iderspecificupdatecontainermappinginput.go | 61 ++ ...l_updateprotectioncontainermappinginput.go | 8 + ...otectioncontainermappinginputproperties.go | 32 + .../model_vmwarecbtcontainermappinginput.go | 46 + ...arecbtprotectioncontainermappingdetails.go | 48 + .../predicates.go | 32 + .../version.go | 12 + .../replicationprotectioncontainers/README.md | 133 +++ .../replicationprotectioncontainers/client.go | 26 + .../id_replicationfabric.go | 134 +++ .../id_replicationfabric_test.go | 327 +++++++ .../id_replicationprotectioncontainer.go | 143 +++ .../id_replicationprotectioncontainer_test.go | 372 ++++++++ .../id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_create.go | 75 ++ .../method_delete.go | 70 ++ .../method_discoverprotectableitem.go | 75 ++ .../method_get.go | 51 ++ .../method_list.go | 91 ++ .../method_listbyreplicationfabrics.go | 91 ++ .../method_switchprotection.go | 75 ++ .../model_a2acontainercreationinput.go | 40 + ...sclustermigrationcontainercreationinput.go | 40 + .../model_a2aswitchprotectioninput.go | 53 ++ .../model_a2avmdiskinputdetails.go | 10 + .../model_a2avmmanageddiskinputdetails.go | 14 + .../model_createprotectioncontainerinput.go | 8 + ...reateprotectioncontainerinputproperties.go | 41 + .../model_discoverprotectableitemrequest.go | 8 + ...iscoverprotectableitemrequestproperties.go | 10 + .../model_diskencryptioninfo.go | 9 + .../model_diskencryptionkeyinfo.go | 9 + .../model_keyencryptionkeyinfo.go | 9 + .../model_protectioncontainer.go | 12 + ...rotectioncontainerfabricspecificdetails.go | 8 + .../model_protectioncontainerproperties.go | 14 + ...nproviderspecificcontainercreationinput.go | 69 ++ .../model_switchprotectioninput.go | 8 + .../model_switchprotectioninputproperties.go | 40 + ...l_switchprotectionproviderspecificinput.go | 53 ++ .../model_vmwarecbtcontainercreationinput.go | 40 + .../predicates.go | 32 + .../version.go | 12 + .../replicationprotectionintents/README.md | 74 ++ .../replicationprotectionintents/client.go | 26 + .../replicationprotectionintents/constants.go | 218 +++++ .../id_replicationprotectionintent.go | 134 +++ .../id_replicationprotectionintent_test.go | 327 +++++++ .../replicationprotectionintents/id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_create.go | 55 ++ .../method_get.go | 51 ++ .../method_list.go | 123 +++ .../model_a2acreateprotectionintentinput.go | 143 +++ ...del_a2aprotectionintentdiskinputdetails.go | 49 ++ ...protectionintentmanageddiskinputdetails.go | 57 ++ .../model_a2areplicationintentdetails.go | 143 +++ .../model_createprotectionintentinput.go | 8 + .../model_createprotectionintentproperties.go | 32 + ...protectionintentproviderspecificdetails.go | 53 ++ .../model_diskencryptioninfo.go | 9 + .../model_diskencryptionkeyinfo.go | 9 + .../model_existingprotectionprofile.go | 41 + .../model_existingrecoveryavailabilityset.go | 41 + ...existingrecoveryproximityplacementgroup.go | 41 + ...l_existingrecoveryrecoveryresourcegroup.go | 41 + .../model_existingrecoveryvirtualnetwork.go | 42 + .../model_existingstorageaccount.go | 41 + .../model_keyencryptionkeyinfo.go | 9 + .../model_newprotectionprofile.go | 45 + .../model_newrecoveryvirtualnetwork.go | 42 + .../model_protectionprofilecustomdetails.go | 61 ++ ...el_recoveryavailabilitysetcustomdetails.go | 53 ++ ...eryproximityplacementgroupcustomdetails.go | 53 ++ ...odel_recoveryresourcegroupcustomdetails.go | 53 ++ ...del_recoveryvirtualnetworkcustomdetails.go | 61 ++ .../model_replicationprotectionintent.go | 12 + ...l_replicationprotectionintentproperties.go | 48 + ...rotectionintentproviderspecificsettings.go | 53 ++ .../model_storageaccountcustomdetails.go | 53 ++ .../predicates.go | 32 + .../replicationprotectionintents/version.go | 12 + .../replicationrecoveryplans/README.md | 203 +++++ .../replicationrecoveryplans/client.go | 26 + .../replicationrecoveryplans/constants.go | 691 +++++++++++++++ .../id_replicationrecoveryplan.go | 134 +++ .../id_replicationrecoveryplan_test.go | 327 +++++++ .../replicationrecoveryplans/id_vault.go | 125 +++ .../replicationrecoveryplans/id_vault_test.go | 282 ++++++ .../replicationrecoveryplans/method_create.go | 75 ++ .../replicationrecoveryplans/method_delete.go | 70 ++ .../method_failovercancel.go | 71 ++ .../method_failovercommit.go | 71 ++ .../replicationrecoveryplans/method_get.go | 51 ++ .../replicationrecoveryplans/method_list.go | 91 ++ .../method_plannedfailover.go | 75 ++ .../method_reprotect.go | 71 ++ .../method_testfailover.go | 75 ++ .../method_testfailovercleanup.go | 75 ++ .../method_unplannedfailover.go | 75 ++ .../replicationrecoveryplans/method_update.go | 75 ++ .../model_createrecoveryplaninput.go | 8 + ...model_createrecoveryplaninputproperties.go | 55 ++ .../model_currentscenariodetails.go | 28 + .../model_recoveryplan.go | 12 + .../model_recoveryplana2adetails.go | 46 + .../model_recoveryplana2afailoverinput.go | 43 + .../model_recoveryplana2ainput.go | 46 + .../model_recoveryplanaction.go | 44 + .../model_recoveryplanactiondetails.go | 69 ++ ...overyplanautomationrunbookactiondetails.go | 43 + .../model_recoveryplangroup.go | 11 + ...veryplanhypervreplicaazurefailbackinput.go | 42 + ...veryplanhypervreplicaazurefailoverinput.go | 43 + ..._recoveryplaninmageazurev2failoverinput.go | 42 + .../model_recoveryplaninmagefailoverinput.go | 41 + ...overyplaninmagercmfailbackfailoverinput.go | 42 + ...odel_recoveryplaninmagercmfailoverinput.go | 42 + .../model_recoveryplanmanualactiondetails.go | 41 + .../model_recoveryplanplannedfailoverinput.go | 8 + ...overyplanplannedfailoverinputproperties.go | 49 ++ .../model_recoveryplanproperties.go | 116 +++ .../model_recoveryplanprotecteditem.go | 9 + ...del_recoveryplanproviderspecificdetails.go | 53 ++ ...coveryplanproviderspecificfailoverinput.go | 101 +++ ...model_recoveryplanproviderspecificinput.go | 53 ++ .../model_recoveryplanscriptactiondetails.go | 43 + ...el_recoveryplantestfailovercleanupinput.go | 8 + ...yplantestfailovercleanupinputproperties.go | 8 + .../model_recoveryplantestfailoverinput.go | 8 + ...recoveryplantestfailoverinputproperties.go | 53 ++ ...odel_recoveryplanunplannedfailoverinput.go | 8 + ...eryplanunplannedfailoverinputproperties.go | 51 ++ .../model_updaterecoveryplaninput.go | 8 + ...model_updaterecoveryplaninputproperties.go | 8 + .../replicationrecoveryplans/predicates.go | 32 + .../replicationrecoveryplans/version.go | 12 + .../README.md | 123 +++ .../client.go | 26 + .../constants.go | 101 +++ .../id_replicationfabric.go | 134 +++ .../id_replicationfabric_test.go | 327 +++++++ .../id_replicationrecoveryservicesprovider.go | 143 +++ ...eplicationrecoveryservicesprovider_test.go | 372 ++++++++ .../id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_create.go | 75 ++ .../method_delete.go | 70 ++ .../method_get.go | 51 ++ .../method_list.go | 91 ++ .../method_listbyreplicationfabrics.go | 91 ++ .../method_purge.go | 70 ++ .../method_refreshprovider.go | 71 ++ .../model_addrecoveryservicesproviderinput.go | 8 + ...recoveryservicesproviderinputproperties.go | 13 + .../model_healtherror.go | 40 + .../model_identityproviderdetails.go | 12 + .../model_identityproviderinput.go | 12 + .../model_innerhealtherror.go | 39 + .../model_recoveryservicesprovider.go | 12 + ...odel_recoveryservicesproviderproperties.go | 57 ++ .../model_versiondetails.go | 28 + .../predicates.go | 32 + .../version.go | 12 + .../README.md | 99 +++ .../client.go | 26 + .../id_replicationstorageclassification.go | 143 +++ ...d_replicationstorageclassification_test.go | 372 ++++++++ ...replicationstorageclassificationmapping.go | 152 ++++ ...cationstorageclassificationmapping_test.go | 417 +++++++++ .../id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_create.go | 75 ++ .../method_delete.go | 70 ++ .../method_get.go | 51 ++ .../method_list.go | 91 ++ ...listbyreplicationstorageclassifications.go | 91 ++ .../model_storageclassificationmapping.go | 12 + ...model_storageclassificationmappinginput.go | 8 + ..._storageclassificationmappingproperties.go | 8 + .../model_storagemappinginputproperties.go | 8 + .../predicates.go | 32 + .../version.go | 12 + .../README.md | 70 ++ .../client.go | 26 + .../id_replicationfabric.go | 134 +++ .../id_replicationfabric_test.go | 327 +++++++ .../id_replicationstorageclassification.go | 143 +++ ...d_replicationstorageclassification_test.go | 372 ++++++++ .../id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../method_get.go | 51 ++ .../method_list.go | 91 ++ .../method_listbyreplicationfabrics.go | 91 ++ .../model_storageclassification.go | 12 + .../model_storageclassificationproperties.go | 8 + .../predicates.go | 32 + .../version.go | 12 + .../replicationvaulthealth/README.md | 48 + .../replicationvaulthealth/client.go | 26 + .../replicationvaulthealth/constants.go | 166 ++++ .../replicationvaulthealth/id_vault.go | 125 +++ .../replicationvaulthealth/id_vault_test.go | 282 ++++++ .../replicationvaulthealth/method_get.go | 52 ++ .../replicationvaulthealth/method_refresh.go | 71 ++ .../model_healtherror.go | 40 + .../model_healtherrorsummary.go | 14 + .../model_innerhealtherror.go | 39 + .../model_resourcehealthsummary.go | 10 + .../model_vaulthealthdetails.go | 12 + .../model_vaulthealthproperties.go | 11 + .../replicationvaulthealth/version.go | 12 + .../replicationvaultsetting/README.md | 70 ++ .../replicationvaultsetting/client.go | 26 + .../id_replicationvaultsetting.go | 134 +++ .../id_replicationvaultsetting_test.go | 327 +++++++ .../replicationvaultsetting/id_vault.go | 125 +++ .../replicationvaultsetting/id_vault_test.go | 282 ++++++ .../replicationvaultsetting/method_create.go | 74 ++ .../replicationvaultsetting/method_get.go | 51 ++ .../replicationvaultsetting/method_list.go | 91 ++ .../model_vaultsetting.go | 12 + .../model_vaultsettingcreationinput.go | 8 + ...del_vaultsettingcreationinputproperties.go | 9 + .../model_vaultsettingproperties.go | 9 + .../replicationvaultsetting/predicates.go | 32 + .../replicationvaultsetting/version.go | 12 + .../2023-08-01/replicationvcenters/README.md | 116 +++ .../2023-08-01/replicationvcenters/client.go | 26 + .../replicationvcenters/constants.go | 51 ++ .../id_replicationfabric.go | 134 +++ .../id_replicationfabric_test.go | 327 +++++++ .../id_replicationvcenter.go | 143 +++ .../id_replicationvcenter_test.go | 372 ++++++++ .../replicationvcenters/id_vault.go | 125 +++ .../replicationvcenters/id_vault_test.go | 282 ++++++ .../replicationvcenters/method_create.go | 75 ++ .../replicationvcenters/method_delete.go | 70 ++ .../replicationvcenters/method_get.go | 51 ++ .../replicationvcenters/method_list.go | 91 ++ .../method_listbyreplicationfabrics.go | 91 ++ .../replicationvcenters/method_update.go | 75 ++ .../model_addvcenterrequest.go | 8 + .../model_addvcenterrequestproperties.go | 12 + .../replicationvcenters/model_healtherror.go | 40 + .../model_innerhealtherror.go | 39 + .../model_updatevcenterrequest.go | 8 + .../model_updatevcenterrequestproperties.go | 12 + .../replicationvcenters/model_vcenter.go | 12 + .../model_vcenterproperties.go | 36 + .../replicationvcenters/predicates.go | 32 + .../2023-08-01/replicationvcenters/version.go | 12 + .../supportedoperatingsystems/README.md | 36 + .../supportedoperatingsystems/client.go | 26 + .../supportedoperatingsystems/id_vault.go | 125 +++ .../id_vault_test.go | 282 ++++++ .../supportedoperatingsystems/method_get.go | 80 ++ .../model_osversionwrapper.go | 9 + .../model_supportedoperatingsystems.go | 12 + .../model_supportedosdetails.go | 10 + .../model_supportedosproperties.go | 8 + .../model_supportedosproperty.go | 9 + .../supportedoperatingsystems/version.go | 12 + .../2023-08-01/targetcomputesizes/README.md | 37 + .../2023-08-01/targetcomputesizes/client.go | 26 + .../id_replicationprotecteditem.go | 152 ++++ .../id_replicationprotecteditem_test.go | 417 +++++++++ .../method_listbyreplicationprotecteditems.go | 91 ++ .../model_computesizeerrordetails.go | 9 + .../model_targetcomputesize.go | 11 + .../model_targetcomputesizeproperties.go | 17 + .../targetcomputesizes/predicates.go | 27 + .../2023-08-01/targetcomputesizes/version.go | 12 + 908 files changed, 65048 insertions(+) create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_migrationrecoverypoint.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_replicationmigrationitem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_replicationmigrationitem_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/model_migrationrecoverypoint.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/operations/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/operations/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/operations/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/operations/model_display.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/operations/model_operationsdiscovery.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/operations/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/operations/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_replicationprotecteditem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_replicationprotecteditem_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/method_listbyreplicationprotecteditems.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_a2arecoverypointdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_inmageazurev2recoverypointdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_inmagercmrecoverypointdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_providerspecificrecoverypointdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_recoverypoint.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_recoverypointproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_replicationalertsetting.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_replicationalertsetting_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_alert.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_alertproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_configurealertrequest.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_configurealertrequestproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_appliancespecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_dradetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmappliancedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmappliancespecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_marsagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_processserverdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_pushinstallerdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_rcmproxydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationappliance.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationapplianceproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_reprotectagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/id_virtualmachine.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/id_virtualmachine_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresults.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_replicationevent.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_replicationevent_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_a2aeventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_event.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventproviderspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplica2012eventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplica2012r2eventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplicaazureeventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplicabaseeventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmageazurev2eventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmagercmeventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmagercmfailbackeventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_jobstatuseventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_vmwarecbteventdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_replicationfabric.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_replicationfabric_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_checkconsistency.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_migratetoaad.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_purge.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_reassociategateway.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_removeinfra.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_renewcertificate.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2aextendedlocationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2afabricspecificlocationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2azonedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_agentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_agentdiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_azurefabriccreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_azurefabricspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_datastore.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_dradetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabric.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabriccreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabriccreationinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricspecificcreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_failoverprocessserverrequest.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_failoverprocessserverrequestproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_hypervhostdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_hypervsitedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_identityproviderdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_identityproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagercmfabriccreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagercmfabricspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_marsagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_mastertargetserver.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_mobilityserviceupdate.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_processserver.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_processserverdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_pushinstallerdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_rcmproxydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_renewcertificateinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_renewcertificateinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_replicationagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_reprotectagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_retentionvolume.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_runasaccount.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_versiondetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmmdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwaredetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwarev2fabriccreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_replicationjob.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_replicationjob_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_cancel.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_export.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_restart.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_resume.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_asrjobdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_asrtask.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_automationrunbooktaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_consistencychecktaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_exportjobdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_failoverjobdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_grouptaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_inconsistentvmdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_inlineworkflowtaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_job.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobentity.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_joberrordetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobqueryparameter.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobtaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_manualactiontaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_providererror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_recoveryplangrouptaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_resumejobparams.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_resumejobparamsproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_scriptactiontaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_serviceerror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_switchprotectionjobdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_tasktypedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_testfailoverjobdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_virtualmachinetaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_vmnicupdatestaskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationfabric.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationfabric_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/model_logicalnetwork.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/model_logicalnetworkproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationmigrationitem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationmigrationitem_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationprotectioncontainer.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_migrate.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_pausereplication.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_resumereplication.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_resync.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_testmigrate.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_testmigratecleanup.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_update.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_appliancemonitoringdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_applianceresourcedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_criticaljobhistorydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_currentjobdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_datastoreutilizationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_gatewayoperationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationitem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationitemproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationproviderspecificsettings.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_pausereplicationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_pausereplicationinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigratecleanupinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationiteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtdiskinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtnicdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtnicinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtresyncinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetwork.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetwork_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetworkmapping.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_listbyreplicationnetworks.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_update.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_createnetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmapping.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmappingproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_updatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationfabric.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationfabric_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationnetwork.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationnetwork_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_listbyreplicationfabrics.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_network.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_networkproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_subnet.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_replicationpolicy.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_replicationpolicy_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_update.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2apolicycreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2apolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_createpolicyinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_createpolicyinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabasepolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabluepolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabluepolicyinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicapolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicapolicyinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmageazurev2policydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmageazurev2policyinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagebasepolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagepolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagepolicyinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmpolicycreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmpolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policy.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproviderspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_updatepolicyinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_updatepolicyinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_vmwarecbtpolicydetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectableitem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectableitem_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectioncontainer.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_configurationsettings.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_diskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_diskvolumedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_inmagediskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_osdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_protectableitem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_protectableitemproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_replicationgroupdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotecteditem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotecteditem_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotectioncontainer.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_adddisks.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_applyrecoverypoint.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_failovercancel.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_failovercommit.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_plannedfailover.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_purge.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_removedisks.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_repairreplication.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_reprotect.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_resolvehealtherrors.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_switchprovider.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_testfailover.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_testfailovercleanup.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_unplannedfailover.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_update.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_updateappliance.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_updatemobilityservice.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aadddisksinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aenableprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aremovedisksinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2areplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2areprotectinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2atestfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmdiskinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_azurevmdiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_currentscenariodetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectioninputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskencryptioninfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskencryptionkeyinfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectioninputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_initialreplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagediskexclusioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageenableprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdiskinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmnicdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmnicinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmreplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmreprotectinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmsyncdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagereplicationdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagereprotectinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagetestfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inputendpoint.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_ipconfigdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_ipconfiginputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_keyencryptionkeyinfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osdiskdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osupgradesupportedversions.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationprotecteditem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationprotecteditemproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationproviderspecificsettings.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealthinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealthinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailovercleanupinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatediskinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatemobilityservicerequest.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_vmnicdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_vmnicinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_purge.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_update.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationfabric.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationfabric_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_discoverprotectableitem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_switchprotection.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2acontainercreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_diskencryptioninfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainerproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectioninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_replicationprotectionintent.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_replicationprotectionintent_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2areplicationintentdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_diskencryptioninfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_diskencryptionkeyinfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingprotectionprofile.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingstorageaccount.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_keyencryptionkeyinfo.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_newprotectionprofile.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_protectionprofilecustomdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintent.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintentproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_storageaccountcustomdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_replicationrecoveryplan.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_failovercancel.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_failovercommit.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_plannedfailover.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_reprotect.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_testfailover.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_testfailovercleanup.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_unplannedfailover.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_update.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_createrecoveryplaninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_currentscenariodetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplan.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2adetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2ainput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanaction.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanactiondetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplangroup.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_updaterecoveryplaninput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationfabric.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_purge.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_refreshprovider.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_identityproviderinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_versiondetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationfabric.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationfabric_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationstorageclassification.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationstorageclassification_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_listbyreplicationfabrics.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/model_storageclassification.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/model_storageclassificationproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/method_refresh.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_healtherrorsummary.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_resourcehealthsummary.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_vaulthealthdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_vaulthealthproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_replicationvaultsetting.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_replicationvaultsetting_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsetting.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingcreationinput.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/constants.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationfabric.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationfabric_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationvcenter.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationvcenter_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_create.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_delete.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_list.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_listbyreplicationfabrics.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_update.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_addvcenterrequest.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_addvcenterrequestproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_healtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_innerhealtherror.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_updatevcenterrequest.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_updatevcenterrequestproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_vcenter.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_vcenterproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/id_vault.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/id_vault_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/method_get.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_osversionwrapper.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedoperatingsystems.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosdetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosproperty.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/version.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/README.md create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/client.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/id_replicationprotecteditem.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/id_replicationprotecteditem_test.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/method_listbyreplicationprotecteditems.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_computesizeerrordetails.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_targetcomputesize.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_targetcomputesizeproperties.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/predicates.go create mode 100644 resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/version.go diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/client.go new file mode 100644 index 00000000000..795c3a0a9f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/client.go @@ -0,0 +1,271 @@ +package v2023_08_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/operations" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + MigrationRecoveryPoints *migrationrecoverypoints.MigrationRecoveryPointsClient + Operations *operations.OperationsClient + RecoveryPoints *recoverypoints.RecoveryPointsClient + ReplicationAlertSettings *replicationalertsettings.ReplicationAlertSettingsClient + ReplicationAppliances *replicationappliances.ReplicationAppliancesClient + ReplicationEligibilityResults *replicationeligibilityresults.ReplicationEligibilityResultsClient + ReplicationEvents *replicationevents.ReplicationEventsClient + ReplicationFabrics *replicationfabrics.ReplicationFabricsClient + ReplicationJobs *replicationjobs.ReplicationJobsClient + ReplicationLogicalNetworks *replicationlogicalnetworks.ReplicationLogicalNetworksClient + ReplicationMigrationItems *replicationmigrationitems.ReplicationMigrationItemsClient + ReplicationNetworkMappings *replicationnetworkmappings.ReplicationNetworkMappingsClient + ReplicationNetworks *replicationnetworks.ReplicationNetworksClient + ReplicationPolicies *replicationpolicies.ReplicationPoliciesClient + ReplicationProtectableItems *replicationprotectableitems.ReplicationProtectableItemsClient + ReplicationProtectedItems *replicationprotecteditems.ReplicationProtectedItemsClient + ReplicationProtectionContainerMappings *replicationprotectioncontainermappings.ReplicationProtectionContainerMappingsClient + ReplicationProtectionContainers *replicationprotectioncontainers.ReplicationProtectionContainersClient + ReplicationProtectionIntents *replicationprotectionintents.ReplicationProtectionIntentsClient + ReplicationRecoveryPlans *replicationrecoveryplans.ReplicationRecoveryPlansClient + ReplicationRecoveryServicesProviders *replicationrecoveryservicesproviders.ReplicationRecoveryServicesProvidersClient + ReplicationStorageClassificationMappings *replicationstorageclassificationmappings.ReplicationStorageClassificationMappingsClient + ReplicationStorageClassifications *replicationstorageclassifications.ReplicationStorageClassificationsClient + ReplicationVaultHealth *replicationvaulthealth.ReplicationVaultHealthClient + ReplicationVaultSetting *replicationvaultsetting.ReplicationVaultSettingClient + ReplicationvCenters *replicationvcenters.ReplicationvCentersClient + SupportedOperatingSystems *supportedoperatingsystems.SupportedOperatingSystemsClient + TargetComputeSizes *targetcomputesizes.TargetComputeSizesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + migrationRecoveryPointsClient, err := migrationrecoverypoints.NewMigrationRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MigrationRecoveryPoints client: %+v", err) + } + configureFunc(migrationRecoveryPointsClient.Client) + + operationsClient, err := operations.NewOperationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Operations client: %+v", err) + } + configureFunc(operationsClient.Client) + + recoveryPointsClient, err := recoverypoints.NewRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RecoveryPoints client: %+v", err) + } + configureFunc(recoveryPointsClient.Client) + + replicationAlertSettingsClient, err := replicationalertsettings.NewReplicationAlertSettingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationAlertSettings client: %+v", err) + } + configureFunc(replicationAlertSettingsClient.Client) + + replicationAppliancesClient, err := replicationappliances.NewReplicationAppliancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationAppliances client: %+v", err) + } + configureFunc(replicationAppliancesClient.Client) + + replicationEligibilityResultsClient, err := replicationeligibilityresults.NewReplicationEligibilityResultsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationEligibilityResults client: %+v", err) + } + configureFunc(replicationEligibilityResultsClient.Client) + + replicationEventsClient, err := replicationevents.NewReplicationEventsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationEvents client: %+v", err) + } + configureFunc(replicationEventsClient.Client) + + replicationFabricsClient, err := replicationfabrics.NewReplicationFabricsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationFabrics client: %+v", err) + } + configureFunc(replicationFabricsClient.Client) + + replicationJobsClient, err := replicationjobs.NewReplicationJobsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationJobs client: %+v", err) + } + configureFunc(replicationJobsClient.Client) + + replicationLogicalNetworksClient, err := replicationlogicalnetworks.NewReplicationLogicalNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationLogicalNetworks client: %+v", err) + } + configureFunc(replicationLogicalNetworksClient.Client) + + replicationMigrationItemsClient, err := replicationmigrationitems.NewReplicationMigrationItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationMigrationItems client: %+v", err) + } + configureFunc(replicationMigrationItemsClient.Client) + + replicationNetworkMappingsClient, err := replicationnetworkmappings.NewReplicationNetworkMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationNetworkMappings client: %+v", err) + } + configureFunc(replicationNetworkMappingsClient.Client) + + replicationNetworksClient, err := replicationnetworks.NewReplicationNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationNetworks client: %+v", err) + } + configureFunc(replicationNetworksClient.Client) + + replicationPoliciesClient, err := replicationpolicies.NewReplicationPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationPolicies client: %+v", err) + } + configureFunc(replicationPoliciesClient.Client) + + replicationProtectableItemsClient, err := replicationprotectableitems.NewReplicationProtectableItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectableItems client: %+v", err) + } + configureFunc(replicationProtectableItemsClient.Client) + + replicationProtectedItemsClient, err := replicationprotecteditems.NewReplicationProtectedItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectedItems client: %+v", err) + } + configureFunc(replicationProtectedItemsClient.Client) + + replicationProtectionContainerMappingsClient, err := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionContainerMappings client: %+v", err) + } + configureFunc(replicationProtectionContainerMappingsClient.Client) + + replicationProtectionContainersClient, err := replicationprotectioncontainers.NewReplicationProtectionContainersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionContainers client: %+v", err) + } + configureFunc(replicationProtectionContainersClient.Client) + + replicationProtectionIntentsClient, err := replicationprotectionintents.NewReplicationProtectionIntentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionIntents client: %+v", err) + } + configureFunc(replicationProtectionIntentsClient.Client) + + replicationRecoveryPlansClient, err := replicationrecoveryplans.NewReplicationRecoveryPlansClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationRecoveryPlans client: %+v", err) + } + configureFunc(replicationRecoveryPlansClient.Client) + + replicationRecoveryServicesProvidersClient, err := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProvidersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationRecoveryServicesProviders client: %+v", err) + } + configureFunc(replicationRecoveryServicesProvidersClient.Client) + + replicationStorageClassificationMappingsClient, err := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationStorageClassificationMappings client: %+v", err) + } + configureFunc(replicationStorageClassificationMappingsClient.Client) + + replicationStorageClassificationsClient, err := replicationstorageclassifications.NewReplicationStorageClassificationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationStorageClassifications client: %+v", err) + } + configureFunc(replicationStorageClassificationsClient.Client) + + replicationVaultHealthClient, err := replicationvaulthealth.NewReplicationVaultHealthClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationVaultHealth client: %+v", err) + } + configureFunc(replicationVaultHealthClient.Client) + + replicationVaultSettingClient, err := replicationvaultsetting.NewReplicationVaultSettingClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationVaultSetting client: %+v", err) + } + configureFunc(replicationVaultSettingClient.Client) + + replicationvCentersClient, err := replicationvcenters.NewReplicationvCentersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationvCenters client: %+v", err) + } + configureFunc(replicationvCentersClient.Client) + + supportedOperatingSystemsClient, err := supportedoperatingsystems.NewSupportedOperatingSystemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SupportedOperatingSystems client: %+v", err) + } + configureFunc(supportedOperatingSystemsClient.Client) + + targetComputeSizesClient, err := targetcomputesizes.NewTargetComputeSizesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TargetComputeSizes client: %+v", err) + } + configureFunc(targetComputeSizesClient.Client) + + return &Client{ + MigrationRecoveryPoints: migrationRecoveryPointsClient, + Operations: operationsClient, + RecoveryPoints: recoveryPointsClient, + ReplicationAlertSettings: replicationAlertSettingsClient, + ReplicationAppliances: replicationAppliancesClient, + ReplicationEligibilityResults: replicationEligibilityResultsClient, + ReplicationEvents: replicationEventsClient, + ReplicationFabrics: replicationFabricsClient, + ReplicationJobs: replicationJobsClient, + ReplicationLogicalNetworks: replicationLogicalNetworksClient, + ReplicationMigrationItems: replicationMigrationItemsClient, + ReplicationNetworkMappings: replicationNetworkMappingsClient, + ReplicationNetworks: replicationNetworksClient, + ReplicationPolicies: replicationPoliciesClient, + ReplicationProtectableItems: replicationProtectableItemsClient, + ReplicationProtectedItems: replicationProtectedItemsClient, + ReplicationProtectionContainerMappings: replicationProtectionContainerMappingsClient, + ReplicationProtectionContainers: replicationProtectionContainersClient, + ReplicationProtectionIntents: replicationProtectionIntentsClient, + ReplicationRecoveryPlans: replicationRecoveryPlansClient, + ReplicationRecoveryServicesProviders: replicationRecoveryServicesProvidersClient, + ReplicationStorageClassificationMappings: replicationStorageClassificationMappingsClient, + ReplicationStorageClassifications: replicationStorageClassificationsClient, + ReplicationVaultHealth: replicationVaultHealthClient, + ReplicationVaultSetting: replicationVaultSettingClient, + ReplicationvCenters: replicationvCentersClient, + SupportedOperatingSystems: supportedOperatingSystemsClient, + TargetComputeSizes: targetComputeSizesClient, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/README.md new file mode 100644 index 00000000000..ec8c340e31b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints` Documentation + +The `migrationrecoverypoints` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints" +``` + + +### Client Initialization + +```go +client := migrationrecoverypoints.NewMigrationRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MigrationRecoveryPointsClient.Get` + +```go +ctx := context.TODO() +id := migrationrecoverypoints.NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue", "migrationRecoveryPointValue") + +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: `MigrationRecoveryPointsClient.ListByReplicationMigrationItems` + +```go +ctx := context.TODO() +id := migrationrecoverypoints.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +// alternatively `client.ListByReplicationMigrationItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationMigrationItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/client.go new file mode 100644 index 00000000000..cfb6fea6947 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/client.go @@ -0,0 +1,26 @@ +package migrationrecoverypoints + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationRecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewMigrationRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*MigrationRecoveryPointsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "migrationrecoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MigrationRecoveryPointsClient: %+v", err) + } + + return &MigrationRecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/constants.go new file mode 100644 index 00000000000..a4169de2a21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/constants.go @@ -0,0 +1,54 @@ +package migrationrecoverypoints + +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 MigrationRecoveryPointType string + +const ( + MigrationRecoveryPointTypeApplicationConsistent MigrationRecoveryPointType = "ApplicationConsistent" + MigrationRecoveryPointTypeCrashConsistent MigrationRecoveryPointType = "CrashConsistent" + MigrationRecoveryPointTypeNotSpecified MigrationRecoveryPointType = "NotSpecified" +) + +func PossibleValuesForMigrationRecoveryPointType() []string { + return []string{ + string(MigrationRecoveryPointTypeApplicationConsistent), + string(MigrationRecoveryPointTypeCrashConsistent), + string(MigrationRecoveryPointTypeNotSpecified), + } +} + +func (s *MigrationRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationRecoveryPointType(input string) (*MigrationRecoveryPointType, error) { + vals := map[string]MigrationRecoveryPointType{ + "applicationconsistent": MigrationRecoveryPointTypeApplicationConsistent, + "crashconsistent": MigrationRecoveryPointTypeCrashConsistent, + "notspecified": MigrationRecoveryPointTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationRecoveryPointType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_migrationrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_migrationrecoverypoint.go new file mode 100644 index 00000000000..2a225aaf60e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_migrationrecoverypoint.go @@ -0,0 +1,161 @@ +package migrationrecoverypoints + +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 = &MigrationRecoveryPointId{} + +// MigrationRecoveryPointId is a struct representing the Resource ID for a Migration Recovery Point +type MigrationRecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string + MigrationRecoveryPointName string +} + +// NewMigrationRecoveryPointID returns a new MigrationRecoveryPointId struct +func NewMigrationRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string, migrationRecoveryPointName string) MigrationRecoveryPointId { + return MigrationRecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + MigrationRecoveryPointName: migrationRecoveryPointName, + } +} + +// ParseMigrationRecoveryPointID parses 'input' into a MigrationRecoveryPointId +func ParseMigrationRecoveryPointID(input string) (*MigrationRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&MigrationRecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MigrationRecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMigrationRecoveryPointIDInsensitively parses 'input' case-insensitively into a MigrationRecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseMigrationRecoveryPointIDInsensitively(input string) (*MigrationRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&MigrationRecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MigrationRecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MigrationRecoveryPointId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + if id.MigrationRecoveryPointName, ok = input.Parsed["migrationRecoveryPointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "migrationRecoveryPointName", input) + } + + return nil +} + +// ValidateMigrationRecoveryPointID checks that 'input' can be parsed as a Migration Recovery Point ID +func ValidateMigrationRecoveryPointID(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 := ParseMigrationRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Migration Recovery Point ID +func (id MigrationRecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s/migrationRecoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName, id.MigrationRecoveryPointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Migration Recovery Point ID +func (id MigrationRecoveryPointId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemValue"), + resourceids.StaticSegment("staticMigrationRecoveryPoints", "migrationRecoveryPoints", "migrationRecoveryPoints"), + resourceids.UserSpecifiedSegment("migrationRecoveryPointName", "migrationRecoveryPointValue"), + } +} + +// String returns a human-readable description of this Migration Recovery Point ID +func (id MigrationRecoveryPointId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + fmt.Sprintf("Migration Recovery Point Name: %q", id.MigrationRecoveryPointName), + } + return fmt.Sprintf("Migration Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go new file mode 100644 index 00000000000..d11a13e9b24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go @@ -0,0 +1,462 @@ +package migrationrecoverypoints + +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 = &MigrationRecoveryPointId{} + +func TestNewMigrationRecoveryPointID(t *testing.T) { + id := NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue", "migrationRecoveryPointValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemValue") + } + + if id.MigrationRecoveryPointName != "migrationRecoveryPointValue" { + t.Fatalf("Expected %q but got %q for Segment 'MigrationRecoveryPointName'", id.MigrationRecoveryPointName, "migrationRecoveryPointValue") + } +} + +func TestFormatMigrationRecoveryPointID(t *testing.T) { + actual := NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue", "migrationRecoveryPointValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/migrationRecoveryPoints/migrationRecoveryPointValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMigrationRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MigrationRecoveryPointId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/migrationRecoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/migrationRecoveryPoints/migrationRecoveryPointValue", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationMigrationItemName: "replicationMigrationItemValue", + MigrationRecoveryPointName: "migrationRecoveryPointValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/migrationRecoveryPoints/migrationRecoveryPointValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMigrationRecoveryPointID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + if actual.MigrationRecoveryPointName != v.Expected.MigrationRecoveryPointName { + t.Fatalf("Expected %q but got %q for MigrationRecoveryPointName", v.Expected.MigrationRecoveryPointName, actual.MigrationRecoveryPointName) + } + + } +} + +func TestParseMigrationRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MigrationRecoveryPointId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/migrationRecoveryPoints", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMvAlUe/mIgRaTiOnReCoVeRyPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/migrationRecoveryPoints/migrationRecoveryPointValue", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationMigrationItemName: "replicationMigrationItemValue", + MigrationRecoveryPointName: "migrationRecoveryPointValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/migrationRecoveryPoints/migrationRecoveryPointValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMvAlUe/mIgRaTiOnReCoVeRyPoInTs/mIgRaTiOnReCoVeRyPoInTvAlUe", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMvAlUe", + MigrationRecoveryPointName: "mIgRaTiOnReCoVeRyPoInTvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMvAlUe/mIgRaTiOnReCoVeRyPoInTs/mIgRaTiOnReCoVeRyPoInTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMigrationRecoveryPointIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + if actual.MigrationRecoveryPointName != v.Expected.MigrationRecoveryPointName { + t.Fatalf("Expected %q but got %q for MigrationRecoveryPointName", v.Expected.MigrationRecoveryPointName, actual.MigrationRecoveryPointName) + } + + } +} + +func TestSegmentsForMigrationRecoveryPointId(t *testing.T) { + segments := MigrationRecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MigrationRecoveryPointId 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/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_replicationmigrationitem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_replicationmigrationitem.go new file mode 100644 index 00000000000..0051124a6a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_replicationmigrationitem.go @@ -0,0 +1,152 @@ +package migrationrecoverypoints + +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 = &ReplicationMigrationItemId{} + +// ReplicationMigrationItemId is a struct representing the Resource ID for a Replication Migration Item +type ReplicationMigrationItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string +} + +// NewReplicationMigrationItemID returns a new ReplicationMigrationItemId struct +func NewReplicationMigrationItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string) ReplicationMigrationItemId { + return ReplicationMigrationItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + } +} + +// ParseReplicationMigrationItemID parses 'input' into a ReplicationMigrationItemId +func ParseReplicationMigrationItemID(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationMigrationItemIDInsensitively parses 'input' case-insensitively into a ReplicationMigrationItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationMigrationItemIDInsensitively(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationMigrationItemId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + return nil +} + +// ValidateReplicationMigrationItemID checks that 'input' can be parsed as a Replication Migration Item ID +func ValidateReplicationMigrationItemID(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 := ParseReplicationMigrationItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Migration Item ID +func (id ReplicationMigrationItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Migration Item ID +func (id ReplicationMigrationItemId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemValue"), + } +} + +// String returns a human-readable description of this Replication Migration Item ID +func (id ReplicationMigrationItemId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + } + return fmt.Sprintf("Replication Migration Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_replicationmigrationitem_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_replicationmigrationitem_test.go new file mode 100644 index 00000000000..a5fe0af13fa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/id_replicationmigrationitem_test.go @@ -0,0 +1,417 @@ +package migrationrecoverypoints + +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 = &ReplicationMigrationItemId{} + +func TestNewReplicationMigrationItemID(t *testing.T) { + id := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemValue") + } +} + +func TestFormatReplicationMigrationItemID(t *testing.T) { + actual := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationMigrationItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationMigrationItemName: "replicationMigrationItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestParseReplicationMigrationItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationMigrationItemName: "replicationMigrationItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMvAlUe", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestSegmentsForReplicationMigrationItemId(t *testing.T) { + segments := ReplicationMigrationItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationMigrationItemId 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/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/method_get.go new file mode 100644 index 00000000000..db7653b9612 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/method_get.go @@ -0,0 +1,51 @@ +package migrationrecoverypoints + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrationRecoveryPoint +} + +// Get ... +func (c MigrationRecoveryPointsClient) Get(ctx context.Context, id MigrationRecoveryPointId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go new file mode 100644 index 00000000000..1c5d1a5e387 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go @@ -0,0 +1,91 @@ +package migrationrecoverypoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationMigrationItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationRecoveryPoint +} + +type ListByReplicationMigrationItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationRecoveryPoint +} + +// ListByReplicationMigrationItems ... +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItems(ctx context.Context, id ReplicationMigrationItemId) (result ListByReplicationMigrationItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrationRecoveryPoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MigrationRecoveryPoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationMigrationItemsComplete retrieves all the results into a single object +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItemsComplete(ctx context.Context, id ReplicationMigrationItemId) (ListByReplicationMigrationItemsCompleteResult, error) { + return c.ListByReplicationMigrationItemsCompleteMatchingPredicate(ctx, id, MigrationRecoveryPointOperationPredicate{}) +} + +// ListByReplicationMigrationItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationMigrationItemId, predicate MigrationRecoveryPointOperationPredicate) (result ListByReplicationMigrationItemsCompleteResult, err error) { + items := make([]MigrationRecoveryPoint, 0) + + resp, err := c.ListByReplicationMigrationItems(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationMigrationItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/model_migrationrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/model_migrationrecoverypoint.go new file mode 100644 index 00000000000..6b0ba9fb2d1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/model_migrationrecoverypoint.go @@ -0,0 +1,12 @@ +package migrationrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationRecoveryPoint struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrationRecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go new file mode 100644 index 00000000000..65f481c3cb9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go @@ -0,0 +1,27 @@ +package migrationrecoverypoints + +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 MigrationRecoveryPointProperties struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *MigrationRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +func (o *MigrationRecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationRecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/predicates.go new file mode 100644 index 00000000000..62a451ad032 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/predicates.go @@ -0,0 +1,32 @@ +package migrationrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationRecoveryPointOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MigrationRecoveryPointOperationPredicate) Matches(input MigrationRecoveryPoint) bool { + + 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/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/version.go new file mode 100644 index 00000000000..79dd46d47c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/migrationrecoverypoints/version.go @@ -0,0 +1,12 @@ +package migrationrecoverypoints + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/migrationrecoverypoints/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/README.md new file mode 100644 index 00000000000..901dd5eaf72 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/operations` Documentation + +The `operations` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/operations" +``` + + +### Client Initialization + +```go +client := operations.NewOperationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OperationsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/client.go new file mode 100644 index 00000000000..304a17c8d48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/client.go @@ -0,0 +1,26 @@ +package operations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationsClient struct { + Client *resourcemanager.Client +} + +func NewOperationsClientWithBaseURI(sdkApi sdkEnv.Api) (*OperationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "operations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OperationsClient: %+v", err) + } + + return &OperationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/method_list.go new file mode 100644 index 00000000000..e4f6bfc92b8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/method_list.go @@ -0,0 +1,92 @@ +package operations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OperationsDiscovery +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []OperationsDiscovery +} + +// List ... +func (c OperationsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/operations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OperationsDiscovery `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c OperationsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, OperationsDiscoveryOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OperationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate OperationsDiscoveryOperationPredicate) (result ListCompleteResult, err error) { + items := make([]OperationsDiscovery, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/model_display.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/model_display.go new file mode 100644 index 00000000000..9b13c14d48d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/model_display.go @@ -0,0 +1,11 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Display struct { + Description *string `json:"description,omitempty"` + Operation *string `json:"operation,omitempty"` + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/model_operationsdiscovery.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/model_operationsdiscovery.go new file mode 100644 index 00000000000..fbd67f9e9f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/model_operationsdiscovery.go @@ -0,0 +1,11 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationsDiscovery struct { + Display *Display `json:"display,omitempty"` + Name *string `json:"name,omitempty"` + Origin *string `json:"origin,omitempty"` + Properties *interface{} `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/predicates.go new file mode 100644 index 00000000000..6c9c733282f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/predicates.go @@ -0,0 +1,27 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationsDiscoveryOperationPredicate struct { + Name *string + Origin *string + Properties *interface{} +} + +func (p OperationsDiscoveryOperationPredicate) Matches(input OperationsDiscovery) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Origin != nil && (input.Origin == nil || *p.Origin != *input.Origin) { + return false + } + + if p.Properties != nil && (input.Properties == nil || *p.Properties != *input.Properties) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/version.go new file mode 100644 index 00000000000..5fa26ee2a0f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/operations/version.go @@ -0,0 +1,12 @@ +package operations + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/operations/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/README.md new file mode 100644 index 00000000000..ba4d3ce5e16 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints` Documentation + +The `recoverypoints` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-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", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue", "recoveryPointValue") + +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.ListByReplicationProtectedItems` + +```go +ctx := context.TODO() +id := recoverypoints.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +// alternatively `client.ListByReplicationProtectedItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectedItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/client.go new file mode 100644 index 00000000000..b6a8f2dda6b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/client.go @@ -0,0 +1,26 @@ +package recoverypoints + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*RecoveryPointsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "recoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecoveryPointsClient: %+v", err) + } + + return &RecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/constants.go new file mode 100644 index 00000000000..db07d9b75c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/constants.go @@ -0,0 +1,51 @@ +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 RecoveryPointSyncType string + +const ( + RecoveryPointSyncTypeMultiVMSyncRecoveryPoint RecoveryPointSyncType = "MultiVmSyncRecoveryPoint" + RecoveryPointSyncTypePerVMRecoveryPoint RecoveryPointSyncType = "PerVmRecoveryPoint" +) + +func PossibleValuesForRecoveryPointSyncType() []string { + return []string{ + string(RecoveryPointSyncTypeMultiVMSyncRecoveryPoint), + string(RecoveryPointSyncTypePerVMRecoveryPoint), + } +} + +func (s *RecoveryPointSyncType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointSyncType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointSyncType(input string) (*RecoveryPointSyncType, error) { + vals := map[string]RecoveryPointSyncType{ + "multivmsyncrecoverypoint": RecoveryPointSyncTypeMultiVMSyncRecoveryPoint, + "pervmrecoverypoint": RecoveryPointSyncTypePerVMRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointSyncType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_recoverypoint.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_recoverypoint.go new file mode 100644 index 00000000000..8d669a78212 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-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 + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string + RecoveryPointName string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string, recoveryPointName string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + RecoveryPointName: recoveryPointName, + } +} + +// 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + if id.RecoveryPointName, ok = input.Parsed["recoveryPointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointName", 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/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName, id.RecoveryPointName) +} + +// 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointName", "recoveryPointValue"), + } +} + +// 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + fmt.Sprintf("Recovery Point Name: %q", id.RecoveryPointName), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_recoverypoint_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_recoverypoint_test.go new file mode 100644 index 00000000000..06d660ab176 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-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", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue", "recoveryPointValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemValue") + } + + if id.RecoveryPointName != "recoveryPointValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointName'", id.RecoveryPointName, "recoveryPointValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue", "recoveryPointValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/recoveryPoints/recoveryPointValue" + 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/recoveryPoints/recoveryPointValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectedItemName: "replicationProtectedItemValue", + RecoveryPointName: "recoveryPointValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/recoveryPoints/recoveryPointValue/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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/recoveryPoints/recoveryPointValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectedItemName: "replicationProtectedItemValue", + RecoveryPointName: "recoveryPointValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/recoveryPoints/recoveryPointValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe/rEcOvErYpOiNtS/rEcOvErYpOiNtVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMvAlUe", + RecoveryPointName: "rEcOvErYpOiNtVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe/rEcOvErYpOiNtS/rEcOvErYpOiNtVaLuE/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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +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/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_replicationprotecteditem.go new file mode 100644 index 00000000000..f40d0cc8431 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_replicationprotecteditem.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 = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(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 := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemValue"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..e282e2d38d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/id_replicationprotecteditem_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 = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemValue") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectedItemName: "replicationProtectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectedItemName: "replicationProtectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId 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/recoveryservicessiterecovery/2023-08-01/recoverypoints/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/method_get.go new file mode 100644 index 00000000000..6640d81d3b6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/method_get.go @@ -0,0 +1,51 @@ +package recoverypoints + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPoint +} + +// Get ... +func (c RecoveryPointsClient) Get(ctx context.Context, id RecoveryPointId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/method_listbyreplicationprotecteditems.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/method_listbyreplicationprotecteditems.go new file mode 100644 index 00000000000..faeea506de1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/method_listbyreplicationprotecteditems.go @@ -0,0 +1,91 @@ +package recoverypoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectedItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryPoint +} + +type ListByReplicationProtectedItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryPoint +} + +// ListByReplicationProtectedItems ... +func (c RecoveryPointsClient) ListByReplicationProtectedItems(ctx context.Context, id ReplicationProtectedItemId) (result ListByReplicationProtectedItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recoveryPoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecoveryPoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectedItemsComplete retrieves all the results into a single object +func (c RecoveryPointsClient) ListByReplicationProtectedItemsComplete(ctx context.Context, id ReplicationProtectedItemId) (ListByReplicationProtectedItemsCompleteResult, error) { + return c.ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx, id, RecoveryPointOperationPredicate{}) +} + +// ListByReplicationProtectedItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecoveryPointsClient) ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectedItemId, predicate RecoveryPointOperationPredicate) (result ListByReplicationProtectedItemsCompleteResult, err error) { + items := make([]RecoveryPoint, 0) + + resp, err := c.ListByReplicationProtectedItems(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationProtectedItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_a2arecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_a2arecoverypointdetails.go new file mode 100644 index 00000000000..759b8fbf2b4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_a2arecoverypointdetails.go @@ -0,0 +1,42 @@ +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 _ ProviderSpecificRecoveryPointDetails = A2ARecoveryPointDetails{} + +type A2ARecoveryPointDetails struct { + Disks *[]string `json:"disks,omitempty"` + RecoveryPointSyncType *RecoveryPointSyncType `json:"recoveryPointSyncType,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails +} + +var _ json.Marshaler = A2ARecoveryPointDetails{} + +func (s A2ARecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper A2ARecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ARecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ARecoveryPointDetails: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ARecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_inmageazurev2recoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_inmageazurev2recoverypointdetails.go new file mode 100644 index 00000000000..c4f33dd48fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_inmageazurev2recoverypointdetails.go @@ -0,0 +1,41 @@ +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 _ ProviderSpecificRecoveryPointDetails = InMageAzureV2RecoveryPointDetails{} + +type InMageAzureV2RecoveryPointDetails struct { + IsMultiVMSyncPoint *string `json:"isMultiVmSyncPoint,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails +} + +var _ json.Marshaler = InMageAzureV2RecoveryPointDetails{} + +func (s InMageAzureV2RecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2RecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_inmagercmrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_inmagercmrecoverypointdetails.go new file mode 100644 index 00000000000..3dfe05eb012 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_inmagercmrecoverypointdetails.go @@ -0,0 +1,41 @@ +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 _ ProviderSpecificRecoveryPointDetails = InMageRcmRecoveryPointDetails{} + +type InMageRcmRecoveryPointDetails struct { + IsMultiVMSyncPoint *string `json:"isMultiVmSyncPoint,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails +} + +var _ json.Marshaler = InMageRcmRecoveryPointDetails{} + +func (s InMageRcmRecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmRecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmRecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmRecoveryPointDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmRecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_providerspecificrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_providerspecificrecoverypointdetails.go new file mode 100644 index 00000000000..9ebed7769b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_providerspecificrecoverypointdetails.go @@ -0,0 +1,69 @@ +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 ProviderSpecificRecoveryPointDetails interface { +} + +// RawProviderSpecificRecoveryPointDetailsImpl 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 RawProviderSpecificRecoveryPointDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProviderSpecificRecoveryPointDetailsImplementation(input []byte) (ProviderSpecificRecoveryPointDetails, 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 ProviderSpecificRecoveryPointDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2ARecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ARecoveryPointDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2RecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2RecoveryPointDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmRecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmRecoveryPointDetails: %+v", err) + } + return out, nil + } + + out := RawProviderSpecificRecoveryPointDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_recoverypoint.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_recoverypoint.go new file mode 100644 index 00000000000..cd0df01a0a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_recoverypoint.go @@ -0,0 +1,12 @@ +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 RecoveryPoint struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_recoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_recoverypointproperties.go new file mode 100644 index 00000000000..69ba9472ece --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/model_recoverypointproperties.go @@ -0,0 +1,57 @@ +package recoverypoints + +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. + +type RecoveryPointProperties struct { + ProviderSpecificDetails ProviderSpecificRecoveryPointDetails `json:"providerSpecificDetails"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` +} + +func (o *RecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} + +var _ json.Unmarshaler = &RecoveryPointProperties{} + +func (s *RecoveryPointProperties) UnmarshalJSON(bytes []byte) error { + type alias RecoveryPointProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPointProperties: %+v", err) + } + + s.RecoveryPointTime = decoded.RecoveryPointTime + s.RecoveryPointType = decoded.RecoveryPointType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPointProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalProviderSpecificRecoveryPointDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'RecoveryPointProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/predicates.go new file mode 100644 index 00000000000..599a0311cbf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/predicates.go @@ -0,0 +1,32 @@ +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 RecoveryPointOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPointOperationPredicate) Matches(input RecoveryPoint) bool { + + 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/recoveryservicessiterecovery/2023-08-01/recoverypoints/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/recoverypoints/version.go new file mode 100644 index 00000000000..cec57c6d2be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoverypoints/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/README.md new file mode 100644 index 00000000000..b7888eb960d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings` Documentation + +The `replicationalertsettings` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationalertsettings" +``` + + +### Client Initialization + +```go +client := replicationalertsettings.NewReplicationAlertSettingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationAlertSettingsClient.Create` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationAlertSettingValue") + +payload := replicationalertsettings.ConfigureAlertRequest{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReplicationAlertSettingsClient.Get` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationAlertSettingValue") + +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: `ReplicationAlertSettingsClient.List` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/client.go new file mode 100644 index 00000000000..90dfb249642 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/client.go @@ -0,0 +1,26 @@ +package replicationalertsettings + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationAlertSettingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationAlertSettingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationAlertSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationalertsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationAlertSettingsClient: %+v", err) + } + + return &ReplicationAlertSettingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_replicationalertsetting.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_replicationalertsetting.go new file mode 100644 index 00000000000..0989547ba4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_replicationalertsetting.go @@ -0,0 +1,134 @@ +package replicationalertsettings + +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 = &ReplicationAlertSettingId{} + +// ReplicationAlertSettingId is a struct representing the Resource ID for a Replication Alert Setting +type ReplicationAlertSettingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationAlertSettingName string +} + +// NewReplicationAlertSettingID returns a new ReplicationAlertSettingId struct +func NewReplicationAlertSettingID(subscriptionId string, resourceGroupName string, vaultName string, replicationAlertSettingName string) ReplicationAlertSettingId { + return ReplicationAlertSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationAlertSettingName: replicationAlertSettingName, + } +} + +// ParseReplicationAlertSettingID parses 'input' into a ReplicationAlertSettingId +func ParseReplicationAlertSettingID(input string) (*ReplicationAlertSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationAlertSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationAlertSettingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationAlertSettingIDInsensitively parses 'input' case-insensitively into a ReplicationAlertSettingId +// note: this method should only be used for API response data and not user input +func ParseReplicationAlertSettingIDInsensitively(input string) (*ReplicationAlertSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationAlertSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationAlertSettingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationAlertSettingId) 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.ReplicationAlertSettingName, ok = input.Parsed["replicationAlertSettingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationAlertSettingName", input) + } + + return nil +} + +// ValidateReplicationAlertSettingID checks that 'input' can be parsed as a Replication Alert Setting ID +func ValidateReplicationAlertSettingID(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 := ParseReplicationAlertSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Alert Setting ID +func (id ReplicationAlertSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationAlertSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationAlertSettingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Alert Setting ID +func (id ReplicationAlertSettingId) 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("staticReplicationAlertSettings", "replicationAlertSettings", "replicationAlertSettings"), + resourceids.UserSpecifiedSegment("replicationAlertSettingName", "replicationAlertSettingValue"), + } +} + +// String returns a human-readable description of this Replication Alert Setting ID +func (id ReplicationAlertSettingId) 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("Replication Alert Setting Name: %q", id.ReplicationAlertSettingName), + } + return fmt.Sprintf("Replication Alert Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_replicationalertsetting_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_replicationalertsetting_test.go new file mode 100644 index 00000000000..edbfc53a914 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_replicationalertsetting_test.go @@ -0,0 +1,327 @@ +package replicationalertsettings + +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 = &ReplicationAlertSettingId{} + +func TestNewReplicationAlertSettingID(t *testing.T) { + id := NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationAlertSettingValue") + + 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.ReplicationAlertSettingName != "replicationAlertSettingValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationAlertSettingName'", id.ReplicationAlertSettingName, "replicationAlertSettingValue") + } +} + +func TestFormatReplicationAlertSettingID(t *testing.T) { + actual := NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationAlertSettingValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationAlertSettings/replicationAlertSettingValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationAlertSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationAlertSettingId + }{ + { + // 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/replicationAlertSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationAlertSettings/replicationAlertSettingValue", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationAlertSettingName: "replicationAlertSettingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationAlertSettings/replicationAlertSettingValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationAlertSettingID(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.ReplicationAlertSettingName != v.Expected.ReplicationAlertSettingName { + t.Fatalf("Expected %q but got %q for ReplicationAlertSettingName", v.Expected.ReplicationAlertSettingName, actual.ReplicationAlertSettingName) + } + + } +} + +func TestParseReplicationAlertSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationAlertSettingId + }{ + { + // 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/replicationAlertSettings", + Error: 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/rEpLiCaTiOnAlErTsEtTiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationAlertSettings/replicationAlertSettingValue", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationAlertSettingName: "replicationAlertSettingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationAlertSettings/replicationAlertSettingValue/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/rEpLiCaTiOnAlErTsEtTiNgS/rEpLiCaTiOnAlErTsEtTiNgVaLuE", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationAlertSettingName: "rEpLiCaTiOnAlErTsEtTiNgVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnAlErTsEtTiNgS/rEpLiCaTiOnAlErTsEtTiNgVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationAlertSettingIDInsensitively(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.ReplicationAlertSettingName != v.Expected.ReplicationAlertSettingName { + t.Fatalf("Expected %q but got %q for ReplicationAlertSettingName", v.Expected.ReplicationAlertSettingName, actual.ReplicationAlertSettingName) + } + + } +} + +func TestSegmentsForReplicationAlertSettingId(t *testing.T) { + segments := ReplicationAlertSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationAlertSettingId 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/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_vault.go new file mode 100644 index 00000000000..0896e47bb65 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_vault.go @@ -0,0 +1,125 @@ +package replicationalertsettings + +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/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_vault_test.go new file mode 100644 index 00000000000..652219c796a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationalertsettings + +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/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_create.go new file mode 100644 index 00000000000..e19065d7bc2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_create.go @@ -0,0 +1,55 @@ +package replicationalertsettings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Alert +} + +// Create ... +func (c ReplicationAlertSettingsClient) Create(ctx context.Context, id ReplicationAlertSettingId, input ConfigureAlertRequest) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_get.go new file mode 100644 index 00000000000..f6fcd0ec5cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_get.go @@ -0,0 +1,51 @@ +package replicationalertsettings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Alert +} + +// Get ... +func (c ReplicationAlertSettingsClient) Get(ctx context.Context, id ReplicationAlertSettingId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_list.go new file mode 100644 index 00000000000..b76e1172fe2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/method_list.go @@ -0,0 +1,91 @@ +package replicationalertsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Alert +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Alert +} + +// List ... +func (c ReplicationAlertSettingsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationAlertSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Alert `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationAlertSettingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AlertOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationAlertSettingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate AlertOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Alert, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_alert.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_alert.go new file mode 100644 index 00000000000..003e317d3b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_alert.go @@ -0,0 +1,12 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Alert struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AlertProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_alertproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_alertproperties.go new file mode 100644 index 00000000000..470729facab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_alertproperties.go @@ -0,0 +1,10 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AlertProperties struct { + CustomEmailAddresses *[]string `json:"customEmailAddresses,omitempty"` + Locale *string `json:"locale,omitempty"` + SendToOwners *string `json:"sendToOwners,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_configurealertrequest.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_configurealertrequest.go new file mode 100644 index 00000000000..b914ebe04a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_configurealertrequest.go @@ -0,0 +1,8 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigureAlertRequest struct { + Properties *ConfigureAlertRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_configurealertrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_configurealertrequestproperties.go new file mode 100644 index 00000000000..d5a6752d183 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/model_configurealertrequestproperties.go @@ -0,0 +1,10 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigureAlertRequestProperties struct { + CustomEmailAddresses *[]string `json:"customEmailAddresses,omitempty"` + Locale *string `json:"locale,omitempty"` + SendToOwners *string `json:"sendToOwners,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/predicates.go new file mode 100644 index 00000000000..456cd1b810e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/predicates.go @@ -0,0 +1,32 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AlertOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AlertOperationPredicate) Matches(input Alert) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/version.go new file mode 100644 index 00000000000..df0d423577a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationalertsettings/version.go @@ -0,0 +1,12 @@ +package replicationalertsettings + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationalertsettings/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/README.md new file mode 100644 index 00000000000..ea15d0505b6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances` Documentation + +The `replicationappliances` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationappliances" +``` + + +### Client Initialization + +```go +client := replicationappliances.NewReplicationAppliancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationAppliancesClient.List` + +```go +ctx := context.TODO() +id := replicationappliances.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, replicationappliances.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationappliances.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/client.go new file mode 100644 index 00000000000..1618809f0e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/client.go @@ -0,0 +1,26 @@ +package replicationappliances + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationAppliancesClient struct { + Client *resourcemanager.Client +} + +func NewReplicationAppliancesClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationAppliancesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationappliances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationAppliancesClient: %+v", err) + } + + return &ReplicationAppliancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/constants.go new file mode 100644 index 00000000000..55e598cf7dc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/constants.go @@ -0,0 +1,145 @@ +package replicationappliances + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type RcmComponentStatus string + +const ( + RcmComponentStatusCritical RcmComponentStatus = "Critical" + RcmComponentStatusHealthy RcmComponentStatus = "Healthy" + RcmComponentStatusUnknown RcmComponentStatus = "Unknown" + RcmComponentStatusWarning RcmComponentStatus = "Warning" +) + +func PossibleValuesForRcmComponentStatus() []string { + return []string{ + string(RcmComponentStatusCritical), + string(RcmComponentStatusHealthy), + string(RcmComponentStatusUnknown), + string(RcmComponentStatusWarning), + } +} + +func (s *RcmComponentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRcmComponentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRcmComponentStatus(input string) (*RcmComponentStatus, error) { + vals := map[string]RcmComponentStatus{ + "critical": RcmComponentStatusCritical, + "healthy": RcmComponentStatusHealthy, + "unknown": RcmComponentStatusUnknown, + "warning": RcmComponentStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RcmComponentStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/id_vault.go new file mode 100644 index 00000000000..cc71b537d6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/id_vault.go @@ -0,0 +1,125 @@ +package replicationappliances + +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/recoveryservicessiterecovery/2023-08-01/replicationappliances/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/id_vault_test.go new file mode 100644 index 00000000000..b4e080974fd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationappliances + +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/recoveryservicessiterecovery/2023-08-01/replicationappliances/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/method_list.go new file mode 100644 index 00000000000..ddbf6e35018 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/method_list.go @@ -0,0 +1,119 @@ +package replicationappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationAppliance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationAppliance +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// List ... +func (c ReplicationAppliancesClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationAppliances", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationAppliance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationAppliancesClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationApplianceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationAppliancesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationApplianceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationAppliance, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_appliancespecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_appliancespecificdetails.go new file mode 100644 index 00000000000..634eae68ca2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_appliancespecificdetails.go @@ -0,0 +1,53 @@ +package replicationappliances + +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 ApplianceSpecificDetails interface { +} + +// RawApplianceSpecificDetailsImpl 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 RawApplianceSpecificDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalApplianceSpecificDetailsImplementation(input []byte) (ApplianceSpecificDetails, 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 ApplianceSpecificDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmApplianceSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmApplianceSpecificDetails: %+v", err) + } + return out, nil + } + + out := RawApplianceSpecificDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_dradetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_dradetails.go new file mode 100644 index 00000000000..fcde153537f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_dradetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 DraDetails struct { + BiosId *string `json:"biosId,omitempty"` + ForwardProtectedItemCount *int64 `json:"forwardProtectedItemCount,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ReverseProtectedItemCount *int64 `json:"reverseProtectedItemCount,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *DraDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *DraDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_healtherror.go new file mode 100644 index 00000000000..1780f919219 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationappliances + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmappliancedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmappliancedetails.go new file mode 100644 index 00000000000..df2d5e14881 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmappliancedetails.go @@ -0,0 +1,18 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmApplianceDetails struct { + Dra *DraDetails `json:"dra,omitempty"` + FabricArmId *string `json:"fabricArmId,omitempty"` + Id *string `json:"id,omitempty"` + MarsAgent *MarsAgentDetails `json:"marsAgent,omitempty"` + Name *string `json:"name,omitempty"` + ProcessServer *ProcessServerDetails `json:"processServer,omitempty"` + PushInstaller *PushInstallerDetails `json:"pushInstaller,omitempty"` + RcmProxy *RcmProxyDetails `json:"rcmProxy,omitempty"` + ReplicationAgent *ReplicationAgentDetails `json:"replicationAgent,omitempty"` + ReprotectAgent *ReprotectAgentDetails `json:"reprotectAgent,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageRcmFabricSwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmappliancespecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmappliancespecificdetails.go new file mode 100644 index 00000000000..063308d1671 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmappliancespecificdetails.go @@ -0,0 +1,41 @@ +package replicationappliances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplianceSpecificDetails = InMageRcmApplianceSpecificDetails{} + +type InMageRcmApplianceSpecificDetails struct { + Appliances *[]InMageRcmApplianceDetails `json:"appliances,omitempty"` + + // Fields inherited from ApplianceSpecificDetails +} + +var _ json.Marshaler = InMageRcmApplianceSpecificDetails{} + +func (s InMageRcmApplianceSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmApplianceSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go new file mode 100644 index 00000000000..84a5830cb6b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFabricSwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_innerhealtherror.go new file mode 100644 index 00000000000..76f31c711be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationappliances + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_marsagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_marsagentdetails.go new file mode 100644 index 00000000000..edf0158b990 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_marsagentdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 MarsAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *MarsAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MarsAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_processserverdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_processserverdetails.go new file mode 100644 index 00000000000..43de3ca2697 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_processserverdetails.go @@ -0,0 +1,54 @@ +package replicationappliances + +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 ProcessServerDetails struct { + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + BiosId *string `json:"biosId,omitempty"` + DiskUsageStatus *RcmComponentStatus `json:"diskUsageStatus,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + FreeSpacePercentage *float64 `json:"freeSpacePercentage,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HistoricHealth *ProtectionHealth `json:"historicHealth,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + MemoryUsagePercentage *float64 `json:"memoryUsagePercentage,omitempty"` + MemoryUsageStatus *RcmComponentStatus `json:"memoryUsageStatus,omitempty"` + Name *string `json:"name,omitempty"` + ProcessorUsagePercentage *float64 `json:"processorUsagePercentage,omitempty"` + ProcessorUsageStatus *RcmComponentStatus `json:"processorUsageStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + SystemLoad *int64 `json:"systemLoad,omitempty"` + SystemLoadStatus *RcmComponentStatus `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputStatus *RcmComponentStatus `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + UsedMemoryInBytes *int64 `json:"usedMemoryInBytes,omitempty"` + UsedSpaceInBytes *int64 `json:"usedSpaceInBytes,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ProcessServerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_pushinstallerdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_pushinstallerdetails.go new file mode 100644 index 00000000000..485a5173ab5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_pushinstallerdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 PushInstallerDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *PushInstallerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *PushInstallerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_rcmproxydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_rcmproxydetails.go new file mode 100644 index 00000000000..1d29ef4a653 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_rcmproxydetails.go @@ -0,0 +1,35 @@ +package replicationappliances + +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 RcmProxyDetails struct { + BiosId *string `json:"biosId,omitempty"` + ClientAuthenticationType *string `json:"clientAuthenticationType,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *RcmProxyDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RcmProxyDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationagentdetails.go new file mode 100644 index 00000000000..5147a2d9142 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationagentdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 ReplicationAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReplicationAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationappliance.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationappliance.go new file mode 100644 index 00000000000..65955cd695d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationappliance.go @@ -0,0 +1,8 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationAppliance struct { + Properties *ReplicationApplianceProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationapplianceproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationapplianceproperties.go new file mode 100644 index 00000000000..d814f948d89 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_replicationapplianceproperties.go @@ -0,0 +1,32 @@ +package replicationappliances + +import ( + "encoding/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 ReplicationApplianceProperties struct { + ProviderSpecificDetails ApplianceSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReplicationApplianceProperties{} + +func (s *ReplicationApplianceProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationApplianceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalApplianceSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationApplianceProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_reprotectagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_reprotectagentdetails.go new file mode 100644 index 00000000000..da40fca482c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/model_reprotectagentdetails.go @@ -0,0 +1,50 @@ +package replicationappliances + +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 ReprotectAgentDetails struct { + AccessibleDatastores *[]string `json:"accessibleDatastores,omitempty"` + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastDiscoveryInUtc *string `json:"lastDiscoveryInUtc,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + VcenterId *string `json:"vcenterId,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReprotectAgentDetails) GetLastDiscoveryInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastDiscoveryInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryInUtc = &formatted +} + +func (o *ReprotectAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/predicates.go new file mode 100644 index 00000000000..58258537c8d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/predicates.go @@ -0,0 +1,12 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationApplianceOperationPredicate struct { +} + +func (p ReplicationApplianceOperationPredicate) Matches(input ReplicationAppliance) bool { + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/version.go new file mode 100644 index 00000000000..afb0b783c53 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationappliances/version.go @@ -0,0 +1,12 @@ +package replicationappliances + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationappliances/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/README.md new file mode 100644 index 00000000000..9d76d5b4538 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults` Documentation + +The `replicationeligibilityresults` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults" +``` + + +### Client Initialization + +```go +client := replicationeligibilityresults.NewReplicationEligibilityResultsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationEligibilityResultsClient.Get` + +```go +ctx := context.TODO() +id := replicationeligibilityresults.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineValue") + +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: `ReplicationEligibilityResultsClient.List` + +```go +ctx := context.TODO() +id := replicationeligibilityresults.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineValue") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/client.go new file mode 100644 index 00000000000..e7c9a6e1062 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/client.go @@ -0,0 +1,26 @@ +package replicationeligibilityresults + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationEligibilityResultsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationEligibilityResultsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationeligibilityresults", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationEligibilityResultsClient: %+v", err) + } + + return &ReplicationEligibilityResultsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/id_virtualmachine.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/id_virtualmachine.go new file mode 100644 index 00000000000..3826c0e9adb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/id_virtualmachine.go @@ -0,0 +1,125 @@ +package replicationeligibilityresults + +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 = &VirtualMachineId{} + +// VirtualMachineId is a struct representing the Resource ID for a Virtual Machine +type VirtualMachineId struct { + SubscriptionId string + ResourceGroupName string + VirtualMachineName string +} + +// NewVirtualMachineID returns a new VirtualMachineId struct +func NewVirtualMachineID(subscriptionId string, resourceGroupName string, virtualMachineName string) VirtualMachineId { + return VirtualMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualMachineName: virtualMachineName, + } +} + +// ParseVirtualMachineID parses 'input' into a VirtualMachineId +func ParseVirtualMachineID(input string) (*VirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualMachineIDInsensitively parses 'input' case-insensitively into a VirtualMachineId +// note: this method should only be used for API response data and not user input +func ParseVirtualMachineIDInsensitively(input string) (*VirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualMachineId) 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.VirtualMachineName, ok = input.Parsed["virtualMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualMachineName", input) + } + + return nil +} + +// ValidateVirtualMachineID checks that 'input' can be parsed as a Virtual Machine ID +func ValidateVirtualMachineID(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 := ParseVirtualMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Machine ID +func (id VirtualMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualMachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Machine ID +func (id VirtualMachineId) 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("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticVirtualMachines", "virtualMachines", "virtualMachines"), + resourceids.UserSpecifiedSegment("virtualMachineName", "virtualMachineValue"), + } +} + +// String returns a human-readable description of this Virtual Machine ID +func (id VirtualMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Machine Name: %q", id.VirtualMachineName), + } + return fmt.Sprintf("Virtual Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/id_virtualmachine_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/id_virtualmachine_test.go new file mode 100644 index 00000000000..f0fc6640013 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/id_virtualmachine_test.go @@ -0,0 +1,282 @@ +package replicationeligibilityresults + +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 = &VirtualMachineId{} + +func TestNewVirtualMachineID(t *testing.T) { + id := NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineValue") + + 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.VirtualMachineName != "virtualMachineValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualMachineName'", id.VirtualMachineName, "virtualMachineValue") + } +} + +func TestFormatVirtualMachineID(t *testing.T) { + actual := NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineId + }{ + { + // 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.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineValue", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineName: "virtualMachineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineID(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.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + } +} + +func TestParseVirtualMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineId + }{ + { + // 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.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineValue", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineName: "virtualMachineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEs/vIrTuAlMaChInEvAlUe", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualMachineName: "vIrTuAlMaChInEvAlUe", + }, + }, + { + // 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.cOmPuTe/vIrTuAlMaChInEs/vIrTuAlMaChInEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineIDInsensitively(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.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + } +} + +func TestSegmentsForVirtualMachineId(t *testing.T) { + segments := VirtualMachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualMachineId 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/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/method_get.go new file mode 100644 index 00000000000..811788155a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/method_get.go @@ -0,0 +1,52 @@ +package replicationeligibilityresults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationEligibilityResults +} + +// Get ... +func (c ReplicationEligibilityResultsClient) Get(ctx context.Context, id VirtualMachineId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/replicationEligibilityResults/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/method_list.go new file mode 100644 index 00000000000..97bcec61d60 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/method_list.go @@ -0,0 +1,52 @@ +package replicationeligibilityresults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationEligibilityResultsCollection +} + +// List ... +func (c ReplicationEligibilityResultsClient) List(ctx context.Context, id VirtualMachineId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/replicationEligibilityResults", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresults.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresults.go new file mode 100644 index 00000000000..c14c19713c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresults.go @@ -0,0 +1,11 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationEligibilityResultsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go new file mode 100644 index 00000000000..2dc729eb1ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go @@ -0,0 +1,8 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsCollection struct { + Value *[]ReplicationEligibilityResults `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go new file mode 100644 index 00000000000..a81d7856188 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go @@ -0,0 +1,12 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsErrorInfo struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go new file mode 100644 index 00000000000..ebc67f22629 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go @@ -0,0 +1,9 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsProperties struct { + ClientRequestId *string `json:"clientRequestId,omitempty"` + Errors *[]ReplicationEligibilityResultsErrorInfo `json:"errors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/version.go new file mode 100644 index 00000000000..2fb70c005eb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationeligibilityresults/version.go @@ -0,0 +1,12 @@ +package replicationeligibilityresults + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationeligibilityresults/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/README.md new file mode 100644 index 00000000000..15d128bea59 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents` Documentation + +The `replicationevents` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationevents" +``` + + +### Client Initialization + +```go +client := replicationevents.NewReplicationEventsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationEventsClient.Get` + +```go +ctx := context.TODO() +id := replicationevents.NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationEventValue") + +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: `ReplicationEventsClient.List` + +```go +ctx := context.TODO() +id := replicationevents.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, replicationevents.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationevents.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/client.go new file mode 100644 index 00000000000..dc018af65fe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/client.go @@ -0,0 +1,26 @@ +package replicationevents + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEventsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationEventsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationEventsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationevents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationEventsClient: %+v", err) + } + + return &ReplicationEventsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/constants.go new file mode 100644 index 00000000000..209501caff5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/constants.go @@ -0,0 +1,51 @@ +package replicationevents + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_replicationevent.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_replicationevent.go new file mode 100644 index 00000000000..463c390a26a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_replicationevent.go @@ -0,0 +1,134 @@ +package replicationevents + +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 = &ReplicationEventId{} + +// ReplicationEventId is a struct representing the Resource ID for a Replication Event +type ReplicationEventId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationEventName string +} + +// NewReplicationEventID returns a new ReplicationEventId struct +func NewReplicationEventID(subscriptionId string, resourceGroupName string, vaultName string, replicationEventName string) ReplicationEventId { + return ReplicationEventId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationEventName: replicationEventName, + } +} + +// ParseReplicationEventID parses 'input' into a ReplicationEventId +func ParseReplicationEventID(input string) (*ReplicationEventId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationEventId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationEventId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationEventIDInsensitively parses 'input' case-insensitively into a ReplicationEventId +// note: this method should only be used for API response data and not user input +func ParseReplicationEventIDInsensitively(input string) (*ReplicationEventId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationEventId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationEventId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationEventId) 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.ReplicationEventName, ok = input.Parsed["replicationEventName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationEventName", input) + } + + return nil +} + +// ValidateReplicationEventID checks that 'input' can be parsed as a Replication Event ID +func ValidateReplicationEventID(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 := ParseReplicationEventID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Event ID +func (id ReplicationEventId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationEvents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationEventName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Event ID +func (id ReplicationEventId) 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("staticReplicationEvents", "replicationEvents", "replicationEvents"), + resourceids.UserSpecifiedSegment("replicationEventName", "replicationEventValue"), + } +} + +// String returns a human-readable description of this Replication Event ID +func (id ReplicationEventId) 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("Replication Event Name: %q", id.ReplicationEventName), + } + return fmt.Sprintf("Replication Event (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_replicationevent_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_replicationevent_test.go new file mode 100644 index 00000000000..f1ecc05ae44 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_replicationevent_test.go @@ -0,0 +1,327 @@ +package replicationevents + +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 = &ReplicationEventId{} + +func TestNewReplicationEventID(t *testing.T) { + id := NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationEventValue") + + 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.ReplicationEventName != "replicationEventValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationEventName'", id.ReplicationEventName, "replicationEventValue") + } +} + +func TestFormatReplicationEventID(t *testing.T) { + actual := NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationEventValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationEvents/replicationEventValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationEventID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationEventId + }{ + { + // 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/replicationEvents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationEvents/replicationEventValue", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationEventName: "replicationEventValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationEvents/replicationEventValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationEventID(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.ReplicationEventName != v.Expected.ReplicationEventName { + t.Fatalf("Expected %q but got %q for ReplicationEventName", v.Expected.ReplicationEventName, actual.ReplicationEventName) + } + + } +} + +func TestParseReplicationEventIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationEventId + }{ + { + // 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/replicationEvents", + Error: 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/rEpLiCaTiOnEvEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationEvents/replicationEventValue", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationEventName: "replicationEventValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationEvents/replicationEventValue/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/rEpLiCaTiOnEvEnTs/rEpLiCaTiOnEvEnTvAlUe", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationEventName: "rEpLiCaTiOnEvEnTvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnEvEnTs/rEpLiCaTiOnEvEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationEventIDInsensitively(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.ReplicationEventName != v.Expected.ReplicationEventName { + t.Fatalf("Expected %q but got %q for ReplicationEventName", v.Expected.ReplicationEventName, actual.ReplicationEventName) + } + + } +} + +func TestSegmentsForReplicationEventId(t *testing.T) { + segments := ReplicationEventId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationEventId 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/recoveryservicessiterecovery/2023-08-01/replicationevents/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_vault.go new file mode 100644 index 00000000000..2e867f7ad0f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_vault.go @@ -0,0 +1,125 @@ +package replicationevents + +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/recoveryservicessiterecovery/2023-08-01/replicationevents/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_vault_test.go new file mode 100644 index 00000000000..0db04b21c7b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationevents + +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/recoveryservicessiterecovery/2023-08-01/replicationevents/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/method_get.go new file mode 100644 index 00000000000..dc0924d387c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/method_get.go @@ -0,0 +1,51 @@ +package replicationevents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Event +} + +// Get ... +func (c ReplicationEventsClient) Get(ctx context.Context, id ReplicationEventId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/method_list.go new file mode 100644 index 00000000000..32e0892215b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/method_list.go @@ -0,0 +1,119 @@ +package replicationevents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Event +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Event +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// List ... +func (c ReplicationEventsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationEvents", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Event `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationEventsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, EventOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationEventsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate EventOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Event, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_a2aeventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_a2aeventdetails.go new file mode 100644 index 00000000000..367f037825d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_a2aeventdetails.go @@ -0,0 +1,46 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = A2AEventDetails{} + +type A2AEventDetails struct { + FabricLocation *string `json:"fabricLocation,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + RemoteFabricLocation *string `json:"remoteFabricLocation,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = A2AEventDetails{} + +func (s A2AEventDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AEventDetails: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_event.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_event.go new file mode 100644 index 00000000000..e80daa64ebb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_event.go @@ -0,0 +1,12 @@ +package replicationevents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Event struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *EventProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventproperties.go new file mode 100644 index 00000000000..0f9a16c5443 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventproperties.go @@ -0,0 +1,80 @@ +package replicationevents + +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. + +type EventProperties struct { + AffectedObjectCorrelationId *string `json:"affectedObjectCorrelationId,omitempty"` + AffectedObjectFriendlyName *string `json:"affectedObjectFriendlyName,omitempty"` + Description *string `json:"description,omitempty"` + EventCode *string `json:"eventCode,omitempty"` + EventSpecificDetails EventSpecificDetails `json:"eventSpecificDetails"` + EventType *string `json:"eventType,omitempty"` + FabricId *string `json:"fabricId,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + ProviderSpecificDetails EventProviderSpecificDetails `json:"providerSpecificDetails"` + Severity *string `json:"severity,omitempty"` + TimeOfOccurrence *string `json:"timeOfOccurrence,omitempty"` +} + +func (o *EventProperties) GetTimeOfOccurrenceAsTime() (*time.Time, error) { + if o.TimeOfOccurrence == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeOfOccurrence, "2006-01-02T15:04:05Z07:00") +} + +func (o *EventProperties) SetTimeOfOccurrenceAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeOfOccurrence = &formatted +} + +var _ json.Unmarshaler = &EventProperties{} + +func (s *EventProperties) UnmarshalJSON(bytes []byte) error { + type alias EventProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into EventProperties: %+v", err) + } + + s.AffectedObjectCorrelationId = decoded.AffectedObjectCorrelationId + s.AffectedObjectFriendlyName = decoded.AffectedObjectFriendlyName + s.Description = decoded.Description + s.EventCode = decoded.EventCode + s.EventType = decoded.EventType + s.FabricId = decoded.FabricId + s.HealthErrors = decoded.HealthErrors + s.Severity = decoded.Severity + s.TimeOfOccurrence = decoded.TimeOfOccurrence + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EventProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["eventSpecificDetails"]; ok { + impl, err := unmarshalEventSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'EventSpecificDetails' for 'EventProperties': %+v", err) + } + s.EventSpecificDetails = impl + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalEventProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EventProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventproviderspecificdetails.go new file mode 100644 index 00000000000..b87f2209a77 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventproviderspecificdetails.go @@ -0,0 +1,117 @@ +package replicationevents + +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 EventProviderSpecificDetails interface { +} + +// RawEventProviderSpecificDetailsImpl 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 RawEventProviderSpecificDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalEventProviderSpecificDetailsImplementation(input []byte) (EventProviderSpecificDetails, 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 EventProviderSpecificDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplica2012EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplica2012EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplica2012R2EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplica2012R2EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBaseEventDetails") { + var out HyperVReplicaBaseEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBaseEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtEventDetails: %+v", err) + } + return out, nil + } + + out := RawEventProviderSpecificDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventspecificdetails.go new file mode 100644 index 00000000000..d1da24b3661 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_eventspecificdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +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 EventSpecificDetails interface { +} + +// RawEventSpecificDetailsImpl 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 RawEventSpecificDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalEventSpecificDetailsImplementation(input []byte) (EventSpecificDetails, 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 EventSpecificDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "JobStatus") { + var out JobStatusEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into JobStatusEventDetails: %+v", err) + } + return out, nil + } + + out := RawEventSpecificDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_healtherror.go new file mode 100644 index 00000000000..7739a4360d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationevents + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplica2012eventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplica2012eventdetails.go new file mode 100644 index 00000000000..94a69b46715 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplica2012eventdetails.go @@ -0,0 +1,44 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = HyperVReplica2012EventDetails{} + +type HyperVReplica2012EventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = HyperVReplica2012EventDetails{} + +func (s HyperVReplica2012EventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplica2012EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplica2012EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplica2012EventDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplica2012EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplica2012r2eventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplica2012r2eventdetails.go new file mode 100644 index 00000000000..967ef27775b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplica2012r2eventdetails.go @@ -0,0 +1,44 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = HyperVReplica2012R2EventDetails{} + +type HyperVReplica2012R2EventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = HyperVReplica2012R2EventDetails{} + +func (s HyperVReplica2012R2EventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplica2012R2EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplica2012R2EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplica2012R2EventDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplica2012R2EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplicaazureeventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplicaazureeventdetails.go new file mode 100644 index 00000000000..6294a98f428 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplicaazureeventdetails.go @@ -0,0 +1,43 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = HyperVReplicaAzureEventDetails{} + +type HyperVReplicaAzureEventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = HyperVReplicaAzureEventDetails{} + +func (s HyperVReplicaAzureEventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureEventDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplicabaseeventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplicabaseeventdetails.go new file mode 100644 index 00000000000..910ff1b95e8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_hypervreplicabaseeventdetails.go @@ -0,0 +1,44 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = HyperVReplicaBaseEventDetails{} + +type HyperVReplicaBaseEventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = HyperVReplicaBaseEventDetails{} + +func (s HyperVReplicaBaseEventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBaseEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBaseEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBaseEventDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaBaseEventDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBaseEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmageazurev2eventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmageazurev2eventdetails.go new file mode 100644 index 00000000000..57570a28989 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmageazurev2eventdetails.go @@ -0,0 +1,47 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = InMageAzureV2EventDetails{} + +type InMageAzureV2EventDetails struct { + Category *string `json:"category,omitempty"` + Component *string `json:"component,omitempty"` + CorrectiveAction *string `json:"correctiveAction,omitempty"` + Details *string `json:"details,omitempty"` + EventType *string `json:"eventType,omitempty"` + SiteName *string `json:"siteName,omitempty"` + Summary *string `json:"summary,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = InMageAzureV2EventDetails{} + +func (s InMageAzureV2EventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2EventDetails: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmagercmeventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmagercmeventdetails.go new file mode 100644 index 00000000000..4e7e36ac753 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmagercmeventdetails.go @@ -0,0 +1,48 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = InMageRcmEventDetails{} + +type InMageRcmEventDetails struct { + ApplianceName *string `json:"applianceName,omitempty"` + ComponentDisplayName *string `json:"componentDisplayName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + JobId *string `json:"jobId,omitempty"` + LatestAgentVersion *string `json:"latestAgentVersion,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + ServerType *string `json:"serverType,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = InMageRcmEventDetails{} + +func (s InMageRcmEventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmEventDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmagercmfailbackeventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmagercmfailbackeventdetails.go new file mode 100644 index 00000000000..353002fa657 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_inmagercmfailbackeventdetails.go @@ -0,0 +1,45 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = InMageRcmFailbackEventDetails{} + +type InMageRcmFailbackEventDetails struct { + ApplianceName *string `json:"applianceName,omitempty"` + ComponentDisplayName *string `json:"componentDisplayName,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + ServerType *string `json:"serverType,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = InMageRcmFailbackEventDetails{} + +func (s InMageRcmFailbackEventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackEventDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_innerhealtherror.go new file mode 100644 index 00000000000..357c416c2ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationevents + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_jobstatuseventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_jobstatuseventdetails.go new file mode 100644 index 00000000000..26e8104f7cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_jobstatuseventdetails.go @@ -0,0 +1,44 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventSpecificDetails = JobStatusEventDetails{} + +type JobStatusEventDetails struct { + AffectedObjectType *string `json:"affectedObjectType,omitempty"` + JobFriendlyName *string `json:"jobFriendlyName,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + + // Fields inherited from EventSpecificDetails +} + +var _ json.Marshaler = JobStatusEventDetails{} + +func (s JobStatusEventDetails) MarshalJSON() ([]byte, error) { + type wrapper JobStatusEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling JobStatusEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling JobStatusEventDetails: %+v", err) + } + decoded["instanceType"] = "JobStatus" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling JobStatusEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_vmwarecbteventdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_vmwarecbteventdetails.go new file mode 100644 index 00000000000..fac0b6257cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/model_vmwarecbteventdetails.go @@ -0,0 +1,41 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = VMwareCbtEventDetails{} + +type VMwareCbtEventDetails struct { + MigrationItemName *string `json:"migrationItemName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails +} + +var _ json.Marshaler = VMwareCbtEventDetails{} + +func (s VMwareCbtEventDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtEventDetails: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/predicates.go new file mode 100644 index 00000000000..323e9dc1ff0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/predicates.go @@ -0,0 +1,32 @@ +package replicationevents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p EventOperationPredicate) Matches(input Event) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationevents/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/version.go new file mode 100644 index 00000000000..255ce715c04 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationevents/version.go @@ -0,0 +1,12 @@ +package replicationevents + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationevents/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/README.md new file mode 100644 index 00000000000..8f7d592cd61 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/README.md @@ -0,0 +1,164 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics` Documentation + +The `replicationfabrics` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationfabrics" +``` + + +### Client Initialization + +```go +client := replicationfabrics.NewReplicationFabricsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationFabricsClient.CheckConsistency` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +if err := client.CheckConsistencyThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Create` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +payload := replicationfabrics.FabricCreationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Delete` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Get` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +read, err := client.Get(ctx, id, replicationfabrics.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReplicationFabricsClient.List` + +```go +ctx := context.TODO() +id := replicationfabrics.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationFabricsClient.MigrateToAad` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +if err := client.MigrateToAadThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Purge` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.ReassociateGateway` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +payload := replicationfabrics.FailoverProcessServerRequest{ + // ... +} + + +if err := client.ReassociateGatewayThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.RemoveInfra` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +if err := client.RemoveInfraThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.RenewCertificate` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +payload := replicationfabrics.RenewCertificateInput{ + // ... +} + + +if err := client.RenewCertificateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/client.go new file mode 100644 index 00000000000..678ea71a639 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/client.go @@ -0,0 +1,26 @@ +package replicationfabrics + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationFabricsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationFabricsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationFabricsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationfabrics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationFabricsClient: %+v", err) + } + + return &ReplicationFabricsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/constants.go new file mode 100644 index 00000000000..26c8d7e1b38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/constants.go @@ -0,0 +1,195 @@ +package replicationfabrics + +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 AgentVersionStatus string + +const ( + AgentVersionStatusDeprecated AgentVersionStatus = "Deprecated" + AgentVersionStatusNotSupported AgentVersionStatus = "NotSupported" + AgentVersionStatusSecurityUpdateRequired AgentVersionStatus = "SecurityUpdateRequired" + AgentVersionStatusSupported AgentVersionStatus = "Supported" + AgentVersionStatusUpdateRequired AgentVersionStatus = "UpdateRequired" +) + +func PossibleValuesForAgentVersionStatus() []string { + return []string{ + string(AgentVersionStatusDeprecated), + string(AgentVersionStatusNotSupported), + string(AgentVersionStatusSecurityUpdateRequired), + string(AgentVersionStatusSupported), + string(AgentVersionStatusUpdateRequired), + } +} + +func (s *AgentVersionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentVersionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentVersionStatus(input string) (*AgentVersionStatus, error) { + vals := map[string]AgentVersionStatus{ + "deprecated": AgentVersionStatusDeprecated, + "notsupported": AgentVersionStatusNotSupported, + "securityupdaterequired": AgentVersionStatusSecurityUpdateRequired, + "supported": AgentVersionStatusSupported, + "updaterequired": AgentVersionStatusUpdateRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentVersionStatus(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type RcmComponentStatus string + +const ( + RcmComponentStatusCritical RcmComponentStatus = "Critical" + RcmComponentStatusHealthy RcmComponentStatus = "Healthy" + RcmComponentStatusUnknown RcmComponentStatus = "Unknown" + RcmComponentStatusWarning RcmComponentStatus = "Warning" +) + +func PossibleValuesForRcmComponentStatus() []string { + return []string{ + string(RcmComponentStatusCritical), + string(RcmComponentStatusHealthy), + string(RcmComponentStatusUnknown), + string(RcmComponentStatusWarning), + } +} + +func (s *RcmComponentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRcmComponentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRcmComponentStatus(input string) (*RcmComponentStatus, error) { + vals := map[string]RcmComponentStatus{ + "critical": RcmComponentStatusCritical, + "healthy": RcmComponentStatusHealthy, + "unknown": RcmComponentStatusUnknown, + "warning": RcmComponentStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RcmComponentStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_replicationfabric.go new file mode 100644 index 00000000000..da77142ec48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_replicationfabric.go @@ -0,0 +1,134 @@ +package replicationfabrics + +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 = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_replicationfabric_test.go new file mode 100644 index 00000000000..1c0454d1b3f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationfabrics + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_vault.go new file mode 100644 index 00000000000..2e0df2bcc11 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_vault.go @@ -0,0 +1,125 @@ +package replicationfabrics + +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/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_vault_test.go new file mode 100644 index 00000000000..e60469afd21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationfabrics + +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/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_checkconsistency.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_checkconsistency.go new file mode 100644 index 00000000000..36419d8f8cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_checkconsistency.go @@ -0,0 +1,71 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckConsistencyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// CheckConsistency ... +func (c ReplicationFabricsClient) CheckConsistency(ctx context.Context, id ReplicationFabricId) (result CheckConsistencyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkConsistency", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CheckConsistencyThenPoll performs CheckConsistency then polls until it's completed +func (c ReplicationFabricsClient) CheckConsistencyThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.CheckConsistency(ctx, id) + if err != nil { + return fmt.Errorf("performing CheckConsistency: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CheckConsistency: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_create.go new file mode 100644 index 00000000000..651d923fdab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_create.go @@ -0,0 +1,75 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// Create ... +func (c ReplicationFabricsClient) Create(ctx context.Context, id ReplicationFabricId, input FabricCreationInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationFabricsClient) CreateThenPoll(ctx context.Context, id ReplicationFabricId, input FabricCreationInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_delete.go new file mode 100644 index 00000000000..2c456521a1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_delete.go @@ -0,0 +1,70 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationFabricsClient) Delete(ctx context.Context, id ReplicationFabricId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationFabricsClient) DeleteThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_get.go new file mode 100644 index 00000000000..8d7a6385531 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_get.go @@ -0,0 +1,80 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +type GetOperationOptions struct { + Filter *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// Get ... +func (c ReplicationFabricsClient) Get(ctx context.Context, id ReplicationFabricId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_list.go new file mode 100644 index 00000000000..a34207546d2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_list.go @@ -0,0 +1,91 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Fabric +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Fabric +} + +// List ... +func (c ReplicationFabricsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationFabrics", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Fabric `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationFabricsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, FabricOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationFabricsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate FabricOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Fabric, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_migratetoaad.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_migratetoaad.go new file mode 100644 index 00000000000..b7fcaf76c6e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_migratetoaad.go @@ -0,0 +1,70 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateToAadOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MigrateToAad ... +func (c ReplicationFabricsClient) MigrateToAad(ctx context.Context, id ReplicationFabricId) (result MigrateToAadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migratetoaad", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// MigrateToAadThenPoll performs MigrateToAad then polls until it's completed +func (c ReplicationFabricsClient) MigrateToAadThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.MigrateToAad(ctx, id) + if err != nil { + return fmt.Errorf("performing MigrateToAad: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateToAad: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_purge.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_purge.go new file mode 100644 index 00000000000..23d0862e294 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_purge.go @@ -0,0 +1,70 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationFabricsClient) Purge(ctx context.Context, id ReplicationFabricId) (result PurgeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationFabricsClient) PurgeThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_reassociategateway.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_reassociategateway.go new file mode 100644 index 00000000000..94cc0eb4bae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_reassociategateway.go @@ -0,0 +1,75 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReassociateGatewayOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// ReassociateGateway ... +func (c ReplicationFabricsClient) ReassociateGateway(ctx context.Context, id ReplicationFabricId, input FailoverProcessServerRequest) (result ReassociateGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reassociateGateway", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReassociateGatewayThenPoll performs ReassociateGateway then polls until it's completed +func (c ReplicationFabricsClient) ReassociateGatewayThenPoll(ctx context.Context, id ReplicationFabricId, input FailoverProcessServerRequest) error { + result, err := c.ReassociateGateway(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReassociateGateway: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReassociateGateway: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_removeinfra.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_removeinfra.go new file mode 100644 index 00000000000..242bf25cd2b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_removeinfra.go @@ -0,0 +1,69 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveInfraOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RemoveInfra ... +func (c ReplicationFabricsClient) RemoveInfra(ctx context.Context, id ReplicationFabricId) (result RemoveInfraOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeInfra", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RemoveInfraThenPoll performs RemoveInfra then polls until it's completed +func (c ReplicationFabricsClient) RemoveInfraThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.RemoveInfra(ctx, id) + if err != nil { + return fmt.Errorf("performing RemoveInfra: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveInfra: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_renewcertificate.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_renewcertificate.go new file mode 100644 index 00000000000..ed91ffffebd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/method_renewcertificate.go @@ -0,0 +1,75 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// RenewCertificate ... +func (c ReplicationFabricsClient) RenewCertificate(ctx context.Context, id ReplicationFabricId, input RenewCertificateInput) (result RenewCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renewCertificate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RenewCertificateThenPoll performs RenewCertificate then polls until it's completed +func (c ReplicationFabricsClient) RenewCertificateThenPoll(ctx context.Context, id ReplicationFabricId, input RenewCertificateInput) error { + result, err := c.RenewCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RenewCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RenewCertificate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2aextendedlocationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2aextendedlocationdetails.go new file mode 100644 index 00000000000..4c3f270376d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2aextendedlocationdetails.go @@ -0,0 +1,13 @@ +package replicationfabrics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AExtendedLocationDetails struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2afabricspecificlocationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2afabricspecificlocationdetails.go new file mode 100644 index 00000000000..cf5d60d8f06 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2afabricspecificlocationdetails.go @@ -0,0 +1,23 @@ +package replicationfabrics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AFabricSpecificLocationDetails struct { + InitialPrimaryExtendedLocation *edgezones.Model `json:"initialPrimaryExtendedLocation,omitempty"` + InitialPrimaryFabricLocation *string `json:"initialPrimaryFabricLocation,omitempty"` + InitialPrimaryZone *string `json:"initialPrimaryZone,omitempty"` + InitialRecoveryExtendedLocation *edgezones.Model `json:"initialRecoveryExtendedLocation,omitempty"` + InitialRecoveryFabricLocation *string `json:"initialRecoveryFabricLocation,omitempty"` + InitialRecoveryZone *string `json:"initialRecoveryZone,omitempty"` + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2azonedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2azonedetails.go new file mode 100644 index 00000000000..f4ad23d1c8c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_a2azonedetails.go @@ -0,0 +1,9 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AZoneDetails struct { + Source *string `json:"source,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_agentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_agentdetails.go new file mode 100644 index 00000000000..ec30bdfa82c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_agentdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentDetails struct { + AgentId *string `json:"agentId,omitempty"` + BiosId *string `json:"biosId,omitempty"` + Disks *[]AgentDiskDetails `json:"disks,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + MachineId *string `json:"machineId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_agentdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_agentdiskdetails.go new file mode 100644 index 00000000000..be3e096778e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_agentdiskdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LunId *int64 `json:"lunId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_azurefabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_azurefabriccreationinput.go new file mode 100644 index 00000000000..916dcdb0b32 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_azurefabriccreationinput.go @@ -0,0 +1,41 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreationInput = AzureFabricCreationInput{} + +type AzureFabricCreationInput struct { + Location *string `json:"location,omitempty"` + + // Fields inherited from FabricSpecificCreationInput +} + +var _ json.Marshaler = AzureFabricCreationInput{} + +func (s AzureFabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper AzureFabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFabricCreationInput: %+v", err) + } + decoded["instanceType"] = "Azure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_azurefabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_azurefabricspecificdetails.go new file mode 100644 index 00000000000..367bc0a49ce --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_azurefabricspecificdetails.go @@ -0,0 +1,45 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = AzureFabricSpecificDetails{} + +type AzureFabricSpecificDetails struct { + ContainerIds *[]string `json:"containerIds,omitempty"` + ExtendedLocations *[]A2AExtendedLocationDetails `json:"extendedLocations,omitempty"` + Location *string `json:"location,omitempty"` + LocationDetails *[]A2AFabricSpecificLocationDetails `json:"locationDetails,omitempty"` + Zones *[]A2AZoneDetails `json:"zones,omitempty"` + + // Fields inherited from FabricSpecificDetails +} + +var _ json.Marshaler = AzureFabricSpecificDetails{} + +func (s AzureFabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper AzureFabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFabricSpecificDetails: %+v", err) + } + decoded["instanceType"] = "Azure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_datastore.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_datastore.go new file mode 100644 index 00000000000..e20a79fe8fe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_datastore.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataStore struct { + Capacity *string `json:"capacity,omitempty"` + FreeSpace *string `json:"freeSpace,omitempty"` + SymbolicName *string `json:"symbolicName,omitempty"` + Type *string `json:"type,omitempty"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_dradetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_dradetails.go new file mode 100644 index 00000000000..3e205a58dff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_dradetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 DraDetails struct { + BiosId *string `json:"biosId,omitempty"` + ForwardProtectedItemCount *int64 `json:"forwardProtectedItemCount,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ReverseProtectedItemCount *int64 `json:"reverseProtectedItemCount,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *DraDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *DraDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_encryptiondetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_encryptiondetails.go new file mode 100644 index 00000000000..75278c5e8f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_encryptiondetails.go @@ -0,0 +1,28 @@ +package replicationfabrics + +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 EncryptionDetails struct { + KekCertExpiryDate *string `json:"kekCertExpiryDate,omitempty"` + KekCertThumbprint *string `json:"kekCertThumbprint,omitempty"` + KekState *string `json:"kekState,omitempty"` +} + +func (o *EncryptionDetails) GetKekCertExpiryDateAsTime() (*time.Time, error) { + if o.KekCertExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.KekCertExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *EncryptionDetails) SetKekCertExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.KekCertExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabric.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabric.go new file mode 100644 index 00000000000..025c3ea019c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabric.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Fabric struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FabricProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabriccreationinput.go new file mode 100644 index 00000000000..33f8bdc704c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabriccreationinput.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricCreationInput struct { + Properties *FabricCreationInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabriccreationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabriccreationinputproperties.go new file mode 100644 index 00000000000..5af8a2ed128 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabriccreationinputproperties.go @@ -0,0 +1,32 @@ +package replicationfabrics + +import ( + "encoding/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 FabricCreationInputProperties struct { + CustomDetails FabricSpecificCreationInput `json:"customDetails"` +} + +var _ json.Unmarshaler = &FabricCreationInputProperties{} + +func (s *FabricCreationInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FabricCreationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := unmarshalFabricSpecificCreationInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'FabricCreationInputProperties': %+v", err) + } + s.CustomDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricproperties.go new file mode 100644 index 00000000000..b0392225021 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricproperties.go @@ -0,0 +1,52 @@ +package replicationfabrics + +import ( + "encoding/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 FabricProperties struct { + BcdrState *string `json:"bcdrState,omitempty"` + CustomDetails FabricSpecificDetails `json:"customDetails"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + RolloverEncryptionDetails *EncryptionDetails `json:"rolloverEncryptionDetails,omitempty"` +} + +var _ json.Unmarshaler = &FabricProperties{} + +func (s *FabricProperties) UnmarshalJSON(bytes []byte) error { + type alias FabricProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into FabricProperties: %+v", err) + } + + s.BcdrState = decoded.BcdrState + s.EncryptionDetails = decoded.EncryptionDetails + s.FriendlyName = decoded.FriendlyName + s.Health = decoded.Health + s.HealthErrorDetails = decoded.HealthErrorDetails + s.InternalIdentifier = decoded.InternalIdentifier + s.RolloverEncryptionDetails = decoded.RolloverEncryptionDetails + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FabricProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := unmarshalFabricSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'FabricProperties': %+v", err) + } + s.CustomDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricspecificcreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricspecificcreationinput.go new file mode 100644 index 00000000000..8dbde38163b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricspecificcreationinput.go @@ -0,0 +1,69 @@ +package replicationfabrics + +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 FabricSpecificCreationInput interface { +} + +// RawFabricSpecificCreationInputImpl 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 RawFabricSpecificCreationInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalFabricSpecificCreationInputImplementation(input []byte) (FabricSpecificCreationInput, 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 FabricSpecificCreationInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Azure") { + var out AzureFabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFabricCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmFabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFabricCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareV2") { + var out VMwareV2FabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareV2FabricCreationInput: %+v", err) + } + return out, nil + } + + out := RawFabricSpecificCreationInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricspecificdetails.go new file mode 100644 index 00000000000..2a06cf9d120 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_fabricspecificdetails.go @@ -0,0 +1,93 @@ +package replicationfabrics + +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 FabricSpecificDetails interface { +} + +// RawFabricSpecificDetailsImpl 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 RawFabricSpecificDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalFabricSpecificDetailsImplementation(input []byte) (FabricSpecificDetails, 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 FabricSpecificDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Azure") { + var out AzureFabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFabricSpecificDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVSite") { + var out HyperVSiteDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVSiteDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmFabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFabricSpecificDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMM") { + var out VMmDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMware") { + var out VMwareDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareV2") { + var out VMwareV2FabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareV2FabricSpecificDetails: %+v", err) + } + return out, nil + } + + out := RawFabricSpecificDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_failoverprocessserverrequest.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_failoverprocessserverrequest.go new file mode 100644 index 00000000000..f782d62e870 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_failoverprocessserverrequest.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverProcessServerRequest struct { + Properties *FailoverProcessServerRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_failoverprocessserverrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_failoverprocessserverrequestproperties.go new file mode 100644 index 00000000000..03ea6958e5d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_failoverprocessserverrequestproperties.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverProcessServerRequestProperties struct { + ContainerName *string `json:"containerName,omitempty"` + SourceProcessServerId *string `json:"sourceProcessServerId,omitempty"` + TargetProcessServerId *string `json:"targetProcessServerId,omitempty"` + UpdateType *string `json:"updateType,omitempty"` + VMsToMigrate *[]string `json:"vmsToMigrate,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_healtherror.go new file mode 100644 index 00000000000..50dfa0a791d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationfabrics + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_hypervhostdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_hypervhostdetails.go new file mode 100644 index 00000000000..5a5914edea0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_hypervhostdetails.go @@ -0,0 +1,10 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVHostDetails struct { + Id *string `json:"id,omitempty"` + MarsAgentVersion *string `json:"marsAgentVersion,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_hypervsitedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_hypervsitedetails.go new file mode 100644 index 00000000000..293057fa1f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_hypervsitedetails.go @@ -0,0 +1,41 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = HyperVSiteDetails{} + +type HyperVSiteDetails struct { + HyperVHosts *[]HyperVHostDetails `json:"hyperVHosts,omitempty"` + + // Fields inherited from FabricSpecificDetails +} + +var _ json.Marshaler = HyperVSiteDetails{} + +func (s HyperVSiteDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVSiteDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVSiteDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVSiteDetails: %+v", err) + } + decoded["instanceType"] = "HyperVSite" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVSiteDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_identityproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_identityproviderdetails.go new file mode 100644 index 00000000000..0a005565876 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_identityproviderdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderDetails struct { + AadAuthority *string `json:"aadAuthority,omitempty"` + ApplicationId *string `json:"applicationId,omitempty"` + Audience *string `json:"audience,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_identityproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_identityproviderinput.go new file mode 100644 index 00000000000..95277e41cc9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_identityproviderinput.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderInput struct { + AadAuthority string `json:"aadAuthority"` + ApplicationId string `json:"applicationId"` + Audience string `json:"audience"` + ObjectId string `json:"objectId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go new file mode 100644 index 00000000000..665f9db6edb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageFabricSwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagercmfabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagercmfabriccreationinput.go new file mode 100644 index 00000000000..6e169783cd2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagercmfabriccreationinput.go @@ -0,0 +1,43 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreationInput = InMageRcmFabricCreationInput{} + +type InMageRcmFabricCreationInput struct { + PhysicalSiteId string `json:"physicalSiteId"` + SourceAgentIdentity IdentityProviderInput `json:"sourceAgentIdentity"` + VMwareSiteId string `json:"vmwareSiteId"` + + // Fields inherited from FabricSpecificCreationInput +} + +var _ json.Marshaler = InMageRcmFabricCreationInput{} + +func (s InMageRcmFabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFabricCreationInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagercmfabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagercmfabricspecificdetails.go new file mode 100644 index 00000000000..6d4749c4c1c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_inmagercmfabricspecificdetails.go @@ -0,0 +1,56 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = InMageRcmFabricSpecificDetails{} + +type InMageRcmFabricSpecificDetails struct { + AgentDetails *[]AgentDetails `json:"agentDetails,omitempty"` + ControlPlaneUri *string `json:"controlPlaneUri,omitempty"` + DataPlaneUri *string `json:"dataPlaneUri,omitempty"` + Dras *[]DraDetails `json:"dras,omitempty"` + MarsAgents *[]MarsAgentDetails `json:"marsAgents,omitempty"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + ProcessServers *[]ProcessServerDetails `json:"processServers,omitempty"` + PushInstallers *[]PushInstallerDetails `json:"pushInstallers,omitempty"` + RcmProxies *[]RcmProxyDetails `json:"rcmProxies,omitempty"` + ReplicationAgents *[]ReplicationAgentDetails `json:"replicationAgents,omitempty"` + ReprotectAgents *[]ReprotectAgentDetails `json:"reprotectAgents,omitempty"` + ServiceContainerId *string `json:"serviceContainerId,omitempty"` + ServiceEndpoint *string `json:"serviceEndpoint,omitempty"` + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + SourceAgentIdentityDetails *IdentityProviderDetails `json:"sourceAgentIdentityDetails,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificDetails +} + +var _ json.Marshaler = InMageRcmFabricSpecificDetails{} + +func (s InMageRcmFabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFabricSpecificDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_innerhealtherror.go new file mode 100644 index 00000000000..c14191f79bd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationfabrics + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_marsagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_marsagentdetails.go new file mode 100644 index 00000000000..ed4c6a9d572 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_marsagentdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 MarsAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *MarsAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MarsAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_mastertargetserver.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_mastertargetserver.go new file mode 100644 index 00000000000..a5e06f8b4a6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_mastertargetserver.go @@ -0,0 +1,67 @@ +package replicationfabrics + +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 MasterTargetServer struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + DataStores *[]DataStore `json:"dataStores,omitempty"` + DiskCount *int64 `json:"diskCount,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MarsAgentExpiryDate *string `json:"marsAgentExpiryDate,omitempty"` + MarsAgentVersion *string `json:"marsAgentVersion,omitempty"` + MarsAgentVersionDetails *VersionDetails `json:"marsAgentVersionDetails,omitempty"` + Name *string `json:"name,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + RetentionVolumes *[]RetentionVolume `json:"retentionVolumes,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` +} + +func (o *MasterTargetServer) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} + +func (o *MasterTargetServer) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} + +func (o *MasterTargetServer) GetMarsAgentExpiryDateAsTime() (*time.Time, error) { + if o.MarsAgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.MarsAgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetMarsAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.MarsAgentExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_mobilityserviceupdate.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_mobilityserviceupdate.go new file mode 100644 index 00000000000..aa2c9c06e41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_mobilityserviceupdate.go @@ -0,0 +1,10 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobilityServiceUpdate struct { + OsType *string `json:"osType,omitempty"` + RebootStatus *string `json:"rebootStatus,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_processserver.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_processserver.go new file mode 100644 index 00000000000..60022e3bd47 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_processserver.go @@ -0,0 +1,97 @@ +package replicationfabrics + +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 ProcessServer struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + CpuLoad *string `json:"cpuLoad,omitempty"` + CpuLoadStatus *string `json:"cpuLoadStatus,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HostId *string `json:"hostId,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MachineCount *string `json:"machineCount,omitempty"` + MarsCommunicationStatus *string `json:"marsCommunicationStatus,omitempty"` + MarsRegistrationStatus *string `json:"marsRegistrationStatus,omitempty"` + MemoryUsageStatus *string `json:"memoryUsageStatus,omitempty"` + MobilityServiceUpdates *[]MobilityServiceUpdate `json:"mobilityServiceUpdates,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + PsServiceStatus *string `json:"psServiceStatus,omitempty"` + PsStatsRefreshTime *string `json:"psStatsRefreshTime,omitempty"` + ReplicationPairCount *string `json:"replicationPairCount,omitempty"` + SpaceUsageStatus *string `json:"spaceUsageStatus,omitempty"` + SslCertExpiryDate *string `json:"sslCertExpiryDate,omitempty"` + SslCertExpiryRemainingDays *int64 `json:"sslCertExpiryRemainingDays,omitempty"` + SystemLoad *string `json:"systemLoad,omitempty"` + SystemLoadStatus *string `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputInMBps *int64 `json:"throughputInMBps,omitempty"` + ThroughputStatus *string `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` +} + +func (o *ProcessServer) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} + +func (o *ProcessServer) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} + +func (o *ProcessServer) GetPsStatsRefreshTimeAsTime() (*time.Time, error) { + if o.PsStatsRefreshTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PsStatsRefreshTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetPsStatsRefreshTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PsStatsRefreshTime = &formatted +} + +func (o *ProcessServer) GetSslCertExpiryDateAsTime() (*time.Time, error) { + if o.SslCertExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SslCertExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetSslCertExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SslCertExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_processserverdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_processserverdetails.go new file mode 100644 index 00000000000..dd4118b12a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_processserverdetails.go @@ -0,0 +1,54 @@ +package replicationfabrics + +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 ProcessServerDetails struct { + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + BiosId *string `json:"biosId,omitempty"` + DiskUsageStatus *RcmComponentStatus `json:"diskUsageStatus,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + FreeSpacePercentage *float64 `json:"freeSpacePercentage,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HistoricHealth *ProtectionHealth `json:"historicHealth,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + MemoryUsagePercentage *float64 `json:"memoryUsagePercentage,omitempty"` + MemoryUsageStatus *RcmComponentStatus `json:"memoryUsageStatus,omitempty"` + Name *string `json:"name,omitempty"` + ProcessorUsagePercentage *float64 `json:"processorUsagePercentage,omitempty"` + ProcessorUsageStatus *RcmComponentStatus `json:"processorUsageStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + SystemLoad *int64 `json:"systemLoad,omitempty"` + SystemLoadStatus *RcmComponentStatus `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputStatus *RcmComponentStatus `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + UsedMemoryInBytes *int64 `json:"usedMemoryInBytes,omitempty"` + UsedSpaceInBytes *int64 `json:"usedSpaceInBytes,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ProcessServerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_pushinstallerdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_pushinstallerdetails.go new file mode 100644 index 00000000000..e12d0506fab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_pushinstallerdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 PushInstallerDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *PushInstallerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *PushInstallerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_rcmproxydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_rcmproxydetails.go new file mode 100644 index 00000000000..939904987ef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_rcmproxydetails.go @@ -0,0 +1,35 @@ +package replicationfabrics + +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 RcmProxyDetails struct { + BiosId *string `json:"biosId,omitempty"` + ClientAuthenticationType *string `json:"clientAuthenticationType,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *RcmProxyDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RcmProxyDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_renewcertificateinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_renewcertificateinput.go new file mode 100644 index 00000000000..ab4a712f42d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_renewcertificateinput.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateInput struct { + Properties *RenewCertificateInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_renewcertificateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_renewcertificateinputproperties.go new file mode 100644 index 00000000000..bf4f0b8030e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_renewcertificateinputproperties.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateInputProperties struct { + RenewCertificateType *string `json:"renewCertificateType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_replicationagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_replicationagentdetails.go new file mode 100644 index 00000000000..0e9ca7038c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_replicationagentdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 ReplicationAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReplicationAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_reprotectagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_reprotectagentdetails.go new file mode 100644 index 00000000000..61e5cf92ba5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_reprotectagentdetails.go @@ -0,0 +1,50 @@ +package replicationfabrics + +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 ReprotectAgentDetails struct { + AccessibleDatastores *[]string `json:"accessibleDatastores,omitempty"` + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastDiscoveryInUtc *string `json:"lastDiscoveryInUtc,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + VcenterId *string `json:"vcenterId,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReprotectAgentDetails) GetLastDiscoveryInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastDiscoveryInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryInUtc = &formatted +} + +func (o *ReprotectAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_retentionvolume.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_retentionvolume.go new file mode 100644 index 00000000000..7d9aa7c6801 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_retentionvolume.go @@ -0,0 +1,11 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionVolume struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + FreeSpaceInBytes *int64 `json:"freeSpaceInBytes,omitempty"` + ThresholdPercentage *int64 `json:"thresholdPercentage,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_runasaccount.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_runasaccount.go new file mode 100644 index 00000000000..2339edd7049 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_runasaccount.go @@ -0,0 +1,9 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunAsAccount struct { + AccountId *string `json:"accountId,omitempty"` + AccountName *string `json:"accountName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_versiondetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_versiondetails.go new file mode 100644 index 00000000000..5d74eb7597e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_versiondetails.go @@ -0,0 +1,28 @@ +package replicationfabrics + +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 VersionDetails struct { + ExpiryDate *string `json:"expiryDate,omitempty"` + Status *AgentVersionStatus `json:"status,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *VersionDetails) GetExpiryDateAsTime() (*time.Time, error) { + if o.ExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *VersionDetails) SetExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmmdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmmdetails.go new file mode 100644 index 00000000000..f96234c1306 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmmdetails.go @@ -0,0 +1,40 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = VMmDetails{} + +type VMmDetails struct { + + // Fields inherited from FabricSpecificDetails +} + +var _ json.Marshaler = VMmDetails{} + +func (s VMmDetails) MarshalJSON() ([]byte, error) { + type wrapper VMmDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmDetails: %+v", err) + } + decoded["instanceType"] = "VMM" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwaredetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwaredetails.go new file mode 100644 index 00000000000..ff61dc7f3c5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwaredetails.go @@ -0,0 +1,73 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = VMwareDetails{} + +type VMwareDetails struct { + AgentCount *string `json:"agentCount,omitempty"` + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + CpuLoad *string `json:"cpuLoad,omitempty"` + CpuLoadStatus *string `json:"cpuLoadStatus,omitempty"` + CsServiceStatus *string `json:"csServiceStatus,omitempty"` + DatabaseServerLoad *string `json:"databaseServerLoad,omitempty"` + DatabaseServerLoadStatus *string `json:"databaseServerLoadStatus,omitempty"` + HostName *string `json:"hostName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MasterTargetServers *[]MasterTargetServer `json:"masterTargetServers,omitempty"` + MemoryUsageStatus *string `json:"memoryUsageStatus,omitempty"` + ProcessServerCount *string `json:"processServerCount,omitempty"` + ProcessServers *[]ProcessServer `json:"processServers,omitempty"` + ProtectedServers *string `json:"protectedServers,omitempty"` + PsTemplateVersion *string `json:"psTemplateVersion,omitempty"` + ReplicationPairCount *string `json:"replicationPairCount,omitempty"` + RunAsAccounts *[]RunAsAccount `json:"runAsAccounts,omitempty"` + SpaceUsageStatus *string `json:"spaceUsageStatus,omitempty"` + SslCertExpiryDate *string `json:"sslCertExpiryDate,omitempty"` + SslCertExpiryRemainingDays *int64 `json:"sslCertExpiryRemainingDays,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageFabricSwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` + SystemLoad *string `json:"systemLoad,omitempty"` + SystemLoadStatus *string `json:"systemLoadStatus,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` + WebLoad *string `json:"webLoad,omitempty"` + WebLoadStatus *string `json:"webLoadStatus,omitempty"` + + // Fields inherited from FabricSpecificDetails +} + +var _ json.Marshaler = VMwareDetails{} + +func (s VMwareDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareDetails: %+v", err) + } + decoded["instanceType"] = "VMware" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwarev2fabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwarev2fabriccreationinput.go new file mode 100644 index 00000000000..0c0e41a8b05 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwarev2fabriccreationinput.go @@ -0,0 +1,43 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreationInput = VMwareV2FabricCreationInput{} + +type VMwareV2FabricCreationInput struct { + MigrationSolutionId string `json:"migrationSolutionId"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificCreationInput +} + +var _ json.Marshaler = VMwareV2FabricCreationInput{} + +func (s VMwareV2FabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareV2FabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareV2FabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareV2FabricCreationInput: %+v", err) + } + decoded["instanceType"] = "VMwareV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareV2FabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go new file mode 100644 index 00000000000..ea49db85b19 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go @@ -0,0 +1,47 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = VMwareV2FabricSpecificDetails{} + +type VMwareV2FabricSpecificDetails struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + ProcessServers *[]ProcessServerDetails `json:"processServers,omitempty"` + ServiceContainerId *string `json:"serviceContainerId,omitempty"` + ServiceEndpoint *string `json:"serviceEndpoint,omitempty"` + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificDetails +} + +var _ json.Marshaler = VMwareV2FabricSpecificDetails{} + +func (s VMwareV2FabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareV2FabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareV2FabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareV2FabricSpecificDetails: %+v", err) + } + decoded["instanceType"] = "VMwareV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareV2FabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/predicates.go new file mode 100644 index 00000000000..faded6326cb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/predicates.go @@ -0,0 +1,32 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p FabricOperationPredicate) Matches(input Fabric) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationfabrics/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/version.go new file mode 100644 index 00000000000..6fc5e00dcda --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationfabrics/version.go @@ -0,0 +1,12 @@ +package replicationfabrics + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationfabrics/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/README.md new file mode 100644 index 00000000000..10f9fd2e5e1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs` Documentation + +The `replicationjobs` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationjobs" +``` + + +### Client Initialization + +```go +client := replicationjobs.NewReplicationJobsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationJobsClient.Cancel` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationJobValue") + +if err := client.CancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Export` + +```go +ctx := context.TODO() +id := replicationjobs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := replicationjobs.JobQueryParameter{ + // ... +} + + +if err := client.ExportThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Get` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationJobValue") + +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: `ReplicationJobsClient.List` + +```go +ctx := context.TODO() +id := replicationjobs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, replicationjobs.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationjobs.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationJobsClient.Restart` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationJobValue") + +if err := client.RestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Resume` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationJobValue") + +payload := replicationjobs.ResumeJobParams{ + // ... +} + + +if err := client.ResumeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/client.go new file mode 100644 index 00000000000..bac1b5424c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/client.go @@ -0,0 +1,26 @@ +package replicationjobs + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationJobsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationJobsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationJobsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationjobs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationJobsClient: %+v", err) + } + + return &ReplicationJobsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/constants.go new file mode 100644 index 00000000000..2ad7334b254 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/constants.go @@ -0,0 +1,54 @@ +package replicationjobs + +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 ExportJobOutputSerializationType string + +const ( + ExportJobOutputSerializationTypeExcel ExportJobOutputSerializationType = "Excel" + ExportJobOutputSerializationTypeJson ExportJobOutputSerializationType = "Json" + ExportJobOutputSerializationTypeXml ExportJobOutputSerializationType = "Xml" +) + +func PossibleValuesForExportJobOutputSerializationType() []string { + return []string{ + string(ExportJobOutputSerializationTypeExcel), + string(ExportJobOutputSerializationTypeJson), + string(ExportJobOutputSerializationTypeXml), + } +} + +func (s *ExportJobOutputSerializationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExportJobOutputSerializationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExportJobOutputSerializationType(input string) (*ExportJobOutputSerializationType, error) { + vals := map[string]ExportJobOutputSerializationType{ + "excel": ExportJobOutputSerializationTypeExcel, + "json": ExportJobOutputSerializationTypeJson, + "xml": ExportJobOutputSerializationTypeXml, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExportJobOutputSerializationType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_replicationjob.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_replicationjob.go new file mode 100644 index 00000000000..4021f0e4d83 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_replicationjob.go @@ -0,0 +1,134 @@ +package replicationjobs + +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 = &ReplicationJobId{} + +// ReplicationJobId is a struct representing the Resource ID for a Replication Job +type ReplicationJobId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationJobName string +} + +// NewReplicationJobID returns a new ReplicationJobId struct +func NewReplicationJobID(subscriptionId string, resourceGroupName string, vaultName string, replicationJobName string) ReplicationJobId { + return ReplicationJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationJobName: replicationJobName, + } +} + +// ParseReplicationJobID parses 'input' into a ReplicationJobId +func ParseReplicationJobID(input string) (*ReplicationJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationJobIDInsensitively parses 'input' case-insensitively into a ReplicationJobId +// note: this method should only be used for API response data and not user input +func ParseReplicationJobIDInsensitively(input string) (*ReplicationJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationJobId) 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.ReplicationJobName, ok = input.Parsed["replicationJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationJobName", input) + } + + return nil +} + +// ValidateReplicationJobID checks that 'input' can be parsed as a Replication Job ID +func ValidateReplicationJobID(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 := ParseReplicationJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Job ID +func (id ReplicationJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Job ID +func (id ReplicationJobId) 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("staticReplicationJobs", "replicationJobs", "replicationJobs"), + resourceids.UserSpecifiedSegment("replicationJobName", "replicationJobValue"), + } +} + +// String returns a human-readable description of this Replication Job ID +func (id ReplicationJobId) 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("Replication Job Name: %q", id.ReplicationJobName), + } + return fmt.Sprintf("Replication Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_replicationjob_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_replicationjob_test.go new file mode 100644 index 00000000000..4bdd2f8a6e5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_replicationjob_test.go @@ -0,0 +1,327 @@ +package replicationjobs + +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 = &ReplicationJobId{} + +func TestNewReplicationJobID(t *testing.T) { + id := NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationJobValue") + + 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.ReplicationJobName != "replicationJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationJobName'", id.ReplicationJobName, "replicationJobValue") + } +} + +func TestFormatReplicationJobID(t *testing.T) { + actual := NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationJobs/replicationJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationJobId + }{ + { + // 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/replicationJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationJobs/replicationJobValue", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationJobName: "replicationJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationJobs/replicationJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationJobID(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.ReplicationJobName != v.Expected.ReplicationJobName { + t.Fatalf("Expected %q but got %q for ReplicationJobName", v.Expected.ReplicationJobName, actual.ReplicationJobName) + } + + } +} + +func TestParseReplicationJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationJobId + }{ + { + // 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/replicationJobs", + Error: 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/rEpLiCaTiOnJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationJobs/replicationJobValue", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationJobName: "replicationJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationJobs/replicationJobValue/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/rEpLiCaTiOnJoBs/rEpLiCaTiOnJoBvAlUe", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationJobName: "rEpLiCaTiOnJoBvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnJoBs/rEpLiCaTiOnJoBvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationJobIDInsensitively(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.ReplicationJobName != v.Expected.ReplicationJobName { + t.Fatalf("Expected %q but got %q for ReplicationJobName", v.Expected.ReplicationJobName, actual.ReplicationJobName) + } + + } +} + +func TestSegmentsForReplicationJobId(t *testing.T) { + segments := ReplicationJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationJobId 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/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_vault.go new file mode 100644 index 00000000000..8d8d985c23d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_vault.go @@ -0,0 +1,125 @@ +package replicationjobs + +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/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_vault_test.go new file mode 100644 index 00000000000..37428c8cbc4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationjobs + +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/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_cancel.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_cancel.go new file mode 100644 index 00000000000..6bb93c09237 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_cancel.go @@ -0,0 +1,71 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CancelOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Cancel ... +func (c ReplicationJobsClient) Cancel(ctx context.Context, id ReplicationJobId) (result CancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CancelThenPoll performs Cancel then polls until it's completed +func (c ReplicationJobsClient) CancelThenPoll(ctx context.Context, id ReplicationJobId) error { + result, err := c.Cancel(ctx, id) + if err != nil { + return fmt.Errorf("performing Cancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Cancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_export.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_export.go new file mode 100644 index 00000000000..3744e562e2d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_export.go @@ -0,0 +1,75 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExportOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Export ... +func (c ReplicationJobsClient) Export(ctx context.Context, id VaultId, input JobQueryParameter) (result ExportOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/replicationJobs/export", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExportThenPoll performs Export then polls until it's completed +func (c ReplicationJobsClient) ExportThenPoll(ctx context.Context, id VaultId, input JobQueryParameter) error { + result, err := c.Export(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Export: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Export: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_get.go new file mode 100644 index 00000000000..b70a6944fc2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_get.go @@ -0,0 +1,51 @@ +package replicationjobs + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Get ... +func (c ReplicationJobsClient) Get(ctx context.Context, id ReplicationJobId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_list.go new file mode 100644 index 00000000000..55c6f1b789a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_list.go @@ -0,0 +1,119 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Job +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Job +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// List ... +func (c ReplicationJobsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationJobs", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Job `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationJobsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, JobOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationJobsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate JobOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Job, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_restart.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_restart.go new file mode 100644 index 00000000000..2750aec1de9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_restart.go @@ -0,0 +1,71 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Restart ... +func (c ReplicationJobsClient) Restart(ctx context.Context, id ReplicationJobId) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c ReplicationJobsClient) RestartThenPoll(ctx context.Context, id ReplicationJobId) error { + result, err := c.Restart(ctx, id) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_resume.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_resume.go new file mode 100644 index 00000000000..1470fd97f41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/method_resume.go @@ -0,0 +1,75 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Resume ... +func (c ReplicationJobsClient) Resume(ctx context.Context, id ReplicationJobId, input ResumeJobParams) (result ResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resume", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResumeThenPoll performs Resume then polls until it's completed +func (c ReplicationJobsClient) ResumeThenPoll(ctx context.Context, id ReplicationJobId, input ResumeJobParams) error { + result, err := c.Resume(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Resume: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resume: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_asrjobdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_asrjobdetails.go new file mode 100644 index 00000000000..613b2519e8b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_asrjobdetails.go @@ -0,0 +1,41 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = AsrJobDetails{} + +type AsrJobDetails struct { + + // Fields inherited from JobDetails + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` +} + +var _ json.Marshaler = AsrJobDetails{} + +func (s AsrJobDetails) MarshalJSON() ([]byte, error) { + type wrapper AsrJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AsrJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AsrJobDetails: %+v", err) + } + decoded["instanceType"] = "AsrJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AsrJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_asrtask.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_asrtask.go new file mode 100644 index 00000000000..6837661d7bf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_asrtask.go @@ -0,0 +1,94 @@ +package replicationjobs + +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. + +type ASRTask struct { + AllowedActions *[]string `json:"allowedActions,omitempty"` + CustomDetails TaskTypeDetails `json:"customDetails"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + GroupTaskCustomDetails GroupTaskDetails `json:"groupTaskCustomDetails"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TaskId *string `json:"taskId,omitempty"` + TaskType *string `json:"taskType,omitempty"` +} + +func (o *ASRTask) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ASRTask) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *ASRTask) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ASRTask) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Unmarshaler = &ASRTask{} + +func (s *ASRTask) UnmarshalJSON(bytes []byte) error { + type alias ASRTask + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ASRTask: %+v", err) + } + + s.AllowedActions = decoded.AllowedActions + s.EndTime = decoded.EndTime + s.Errors = decoded.Errors + s.FriendlyName = decoded.FriendlyName + s.Name = decoded.Name + s.StartTime = decoded.StartTime + s.State = decoded.State + s.StateDescription = decoded.StateDescription + s.TaskId = decoded.TaskId + s.TaskType = decoded.TaskType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ASRTask into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := unmarshalTaskTypeDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'ASRTask': %+v", err) + } + s.CustomDetails = impl + } + + if v, ok := temp["groupTaskCustomDetails"]; ok { + impl, err := unmarshalGroupTaskDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'GroupTaskCustomDetails' for 'ASRTask': %+v", err) + } + s.GroupTaskCustomDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_automationrunbooktaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_automationrunbooktaskdetails.go new file mode 100644 index 00000000000..902491069ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_automationrunbooktaskdetails.go @@ -0,0 +1,49 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = AutomationRunbookTaskDetails{} + +type AutomationRunbookTaskDetails struct { + AccountName *string `json:"accountName,omitempty"` + CloudServiceName *string `json:"cloudServiceName,omitempty"` + IsPrimarySideScript *bool `json:"isPrimarySideScript,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobOutput *string `json:"jobOutput,omitempty"` + Name *string `json:"name,omitempty"` + RunbookId *string `json:"runbookId,omitempty"` + RunbookName *string `json:"runbookName,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + + // Fields inherited from TaskTypeDetails +} + +var _ json.Marshaler = AutomationRunbookTaskDetails{} + +func (s AutomationRunbookTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper AutomationRunbookTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutomationRunbookTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutomationRunbookTaskDetails: %+v", err) + } + decoded["instanceType"] = "AutomationRunbookTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutomationRunbookTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_consistencychecktaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_consistencychecktaskdetails.go new file mode 100644 index 00000000000..2a2ee8d055d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_consistencychecktaskdetails.go @@ -0,0 +1,41 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = ConsistencyCheckTaskDetails{} + +type ConsistencyCheckTaskDetails struct { + VMDetails *[]InconsistentVMDetails `json:"vmDetails,omitempty"` + + // Fields inherited from TaskTypeDetails +} + +var _ json.Marshaler = ConsistencyCheckTaskDetails{} + +func (s ConsistencyCheckTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ConsistencyCheckTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ConsistencyCheckTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ConsistencyCheckTaskDetails: %+v", err) + } + decoded["instanceType"] = "ConsistencyCheckTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ConsistencyCheckTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_exportjobdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_exportjobdetails.go new file mode 100644 index 00000000000..eb560e96f4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_exportjobdetails.go @@ -0,0 +1,43 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = ExportJobDetails{} + +type ExportJobDetails struct { + BlobUri *string `json:"blobUri,omitempty"` + SasToken *string `json:"sasToken,omitempty"` + + // Fields inherited from JobDetails + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` +} + +var _ json.Marshaler = ExportJobDetails{} + +func (s ExportJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ExportJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExportJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExportJobDetails: %+v", err) + } + decoded["instanceType"] = "ExportJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExportJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go new file mode 100644 index 00000000000..36b762f33e1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go @@ -0,0 +1,43 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = FabricReplicationGroupTaskDetails{} + +type FabricReplicationGroupTaskDetails struct { + SkippedReason *string `json:"skippedReason,omitempty"` + SkippedReasonString *string `json:"skippedReasonString,omitempty"` + + // Fields inherited from JobTaskDetails + JobTask *JobEntity `json:"jobTask,omitempty"` +} + +var _ json.Marshaler = FabricReplicationGroupTaskDetails{} + +func (s FabricReplicationGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper FabricReplicationGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FabricReplicationGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FabricReplicationGroupTaskDetails: %+v", err) + } + decoded["instanceType"] = "FabricReplicationGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FabricReplicationGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_failoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_failoverjobdetails.go new file mode 100644 index 00000000000..ef618276ce2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_failoverjobdetails.go @@ -0,0 +1,42 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = FailoverJobDetails{} + +type FailoverJobDetails struct { + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + + // Fields inherited from JobDetails + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` +} + +var _ json.Marshaler = FailoverJobDetails{} + +func (s FailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper FailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FailoverJobDetails: %+v", err) + } + decoded["instanceType"] = "FailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go new file mode 100644 index 00000000000..8f28aeba2ed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go @@ -0,0 +1,34 @@ +package replicationjobs + +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 FailoverReplicationProtectedItemDetails struct { + FriendlyName *string `json:"friendlyName,omitempty"` + Name *string `json:"name,omitempty"` + NetworkConnectionStatus *string `json:"networkConnectionStatus,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + Subnet *string `json:"subnet,omitempty"` + TestVMFriendlyName *string `json:"testVmFriendlyName,omitempty"` + TestVMName *string `json:"testVmName,omitempty"` +} + +func (o *FailoverReplicationProtectedItemDetails) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *FailoverReplicationProtectedItemDetails) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_grouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_grouptaskdetails.go new file mode 100644 index 00000000000..5ba48b384a2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_grouptaskdetails.go @@ -0,0 +1,61 @@ +package replicationjobs + +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 GroupTaskDetails interface { +} + +// RawGroupTaskDetailsImpl 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 RawGroupTaskDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalGroupTaskDetailsImplementation(input []byte) (GroupTaskDetails, 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 GroupTaskDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "InlineWorkflowTaskDetails") { + var out InlineWorkflowTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InlineWorkflowTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RecoveryPlanGroupTaskDetails") { + var out RecoveryPlanGroupTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanGroupTaskDetails: %+v", err) + } + return out, nil + } + + out := RawGroupTaskDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_inconsistentvmdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_inconsistentvmdetails.go new file mode 100644 index 00000000000..04192118e25 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_inconsistentvmdetails.go @@ -0,0 +1,11 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InconsistentVMDetails struct { + CloudName *string `json:"cloudName,omitempty"` + Details *[]string `json:"details,omitempty"` + ErrorIds *[]string `json:"errorIds,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_inlineworkflowtaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_inlineworkflowtaskdetails.go new file mode 100644 index 00000000000..1f7381153e8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_inlineworkflowtaskdetails.go @@ -0,0 +1,42 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ GroupTaskDetails = InlineWorkflowTaskDetails{} + +type InlineWorkflowTaskDetails struct { + WorkflowIds *[]string `json:"workflowIds,omitempty"` + + // Fields inherited from GroupTaskDetails + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` +} + +var _ json.Marshaler = InlineWorkflowTaskDetails{} + +func (s InlineWorkflowTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper InlineWorkflowTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InlineWorkflowTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InlineWorkflowTaskDetails: %+v", err) + } + decoded["instanceType"] = "InlineWorkflowTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InlineWorkflowTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_job.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_job.go new file mode 100644 index 00000000000..74a9debce1f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_job.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Job struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *JobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobdetails.go new file mode 100644 index 00000000000..99f681b64dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobdetails.go @@ -0,0 +1,85 @@ +package replicationjobs + +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 JobDetails interface { +} + +// RawJobDetailsImpl 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 RawJobDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalJobDetailsImplementation(input []byte) (JobDetails, 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 JobDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AsrJobDetails") { + var out AsrJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AsrJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ExportJobDetails") { + var out ExportJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExportJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FailoverJobDetails") { + var out FailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FailoverJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SwitchProtectionJobDetails") { + var out SwitchProtectionJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SwitchProtectionJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TestFailoverJobDetails") { + var out TestFailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TestFailoverJobDetails: %+v", err) + } + return out, nil + } + + out := RawJobDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobentity.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobentity.go new file mode 100644 index 00000000000..e3cbaea444e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobentity.go @@ -0,0 +1,13 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobEntity struct { + JobFriendlyName *string `json:"jobFriendlyName,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobScenarioName *string `json:"jobScenarioName,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + TargetObjectId *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_joberrordetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_joberrordetails.go new file mode 100644 index 00000000000..797e2dc1bd1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_joberrordetails.go @@ -0,0 +1,30 @@ +package replicationjobs + +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 JobErrorDetails struct { + CreationTime *string `json:"creationTime,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ProviderErrorDetails *ProviderError `json:"providerErrorDetails,omitempty"` + ServiceErrorDetails *ServiceError `json:"serviceErrorDetails,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *JobErrorDetails) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobErrorDetails) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobproperties.go new file mode 100644 index 00000000000..8e5b41fb325 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobproperties.go @@ -0,0 +1,91 @@ +package replicationjobs + +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. + +type JobProperties struct { + ActivityId *string `json:"activityId,omitempty"` + AllowedActions *[]string `json:"allowedActions,omitempty"` + CustomDetails JobDetails `json:"customDetails"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + TargetObjectId *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` + Tasks *[]ASRTask `json:"tasks,omitempty"` +} + +func (o *JobProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *JobProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Unmarshaler = &JobProperties{} + +func (s *JobProperties) UnmarshalJSON(bytes []byte) error { + type alias JobProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into JobProperties: %+v", err) + } + + s.ActivityId = decoded.ActivityId + s.AllowedActions = decoded.AllowedActions + s.EndTime = decoded.EndTime + s.Errors = decoded.Errors + s.FriendlyName = decoded.FriendlyName + s.ScenarioName = decoded.ScenarioName + s.StartTime = decoded.StartTime + s.State = decoded.State + s.StateDescription = decoded.StateDescription + s.TargetInstanceType = decoded.TargetInstanceType + s.TargetObjectId = decoded.TargetObjectId + s.TargetObjectName = decoded.TargetObjectName + s.Tasks = decoded.Tasks + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := unmarshalJobDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'JobProperties': %+v", err) + } + s.CustomDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobqueryparameter.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobqueryparameter.go new file mode 100644 index 00000000000..bc10a6b6e1d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobqueryparameter.go @@ -0,0 +1,15 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobQueryParameter struct { + AffectedObjectTypes *string `json:"affectedObjectTypes,omitempty"` + EndTime *string `json:"endTime,omitempty"` + FabricId *string `json:"fabricId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobOutputType *ExportJobOutputSerializationType `json:"jobOutputType,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimezoneOffset *float64 `json:"timezoneOffset,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobtaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobtaskdetails.go new file mode 100644 index 00000000000..40a3d24c0d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_jobtaskdetails.go @@ -0,0 +1,41 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = JobTaskDetails{} + +type JobTaskDetails struct { + JobTask *JobEntity `json:"jobTask,omitempty"` + + // Fields inherited from TaskTypeDetails +} + +var _ json.Marshaler = JobTaskDetails{} + +func (s JobTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper JobTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling JobTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling JobTaskDetails: %+v", err) + } + decoded["instanceType"] = "JobTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling JobTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_manualactiontaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_manualactiontaskdetails.go new file mode 100644 index 00000000000..9477eb93f5c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_manualactiontaskdetails.go @@ -0,0 +1,43 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = ManualActionTaskDetails{} + +type ManualActionTaskDetails struct { + Instructions *string `json:"instructions,omitempty"` + Name *string `json:"name,omitempty"` + Observation *string `json:"observation,omitempty"` + + // Fields inherited from TaskTypeDetails +} + +var _ json.Marshaler = ManualActionTaskDetails{} + +func (s ManualActionTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ManualActionTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManualActionTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManualActionTaskDetails: %+v", err) + } + decoded["instanceType"] = "ManualActionTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManualActionTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_providererror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_providererror.go new file mode 100644 index 00000000000..e7f3a6131ee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_providererror.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderError struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_recoveryplangrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_recoveryplangrouptaskdetails.go new file mode 100644 index 00000000000..5a55423d4da --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_recoveryplangrouptaskdetails.go @@ -0,0 +1,44 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ GroupTaskDetails = RecoveryPlanGroupTaskDetails{} + +type RecoveryPlanGroupTaskDetails struct { + GroupId *string `json:"groupId,omitempty"` + Name *string `json:"name,omitempty"` + RpGroupType *string `json:"rpGroupType,omitempty"` + + // Fields inherited from GroupTaskDetails + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` +} + +var _ json.Marshaler = RecoveryPlanGroupTaskDetails{} + +func (s RecoveryPlanGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + decoded["instanceType"] = "RecoveryPlanGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go new file mode 100644 index 00000000000..5ce8bf8aade --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go @@ -0,0 +1,43 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ GroupTaskDetails = RecoveryPlanShutdownGroupTaskDetails{} + +type RecoveryPlanShutdownGroupTaskDetails struct { + + // Fields inherited from RecoveryPlanGroupTaskDetails + GroupId *string `json:"groupId,omitempty"` + Name *string `json:"name,omitempty"` + RpGroupType *string `json:"rpGroupType,omitempty"` +} + +var _ json.Marshaler = RecoveryPlanShutdownGroupTaskDetails{} + +func (s RecoveryPlanShutdownGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanShutdownGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + decoded["instanceType"] = "RecoveryPlanShutdownGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_resumejobparams.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_resumejobparams.go new file mode 100644 index 00000000000..c247d0c303b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_resumejobparams.go @@ -0,0 +1,8 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeJobParams struct { + Properties *ResumeJobParamsProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_resumejobparamsproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_resumejobparamsproperties.go new file mode 100644 index 00000000000..a4dc002b22b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_resumejobparamsproperties.go @@ -0,0 +1,8 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeJobParamsProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_scriptactiontaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_scriptactiontaskdetails.go new file mode 100644 index 00000000000..cf231b16ade --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_scriptactiontaskdetails.go @@ -0,0 +1,44 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = ScriptActionTaskDetails{} + +type ScriptActionTaskDetails struct { + IsPrimarySideScript *bool `json:"isPrimarySideScript,omitempty"` + Name *string `json:"name,omitempty"` + Output *string `json:"output,omitempty"` + Path *string `json:"path,omitempty"` + + // Fields inherited from TaskTypeDetails +} + +var _ json.Marshaler = ScriptActionTaskDetails{} + +func (s ScriptActionTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ScriptActionTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ScriptActionTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ScriptActionTaskDetails: %+v", err) + } + decoded["instanceType"] = "ScriptActionTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ScriptActionTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_serviceerror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_serviceerror.go new file mode 100644 index 00000000000..1ce1b446dc8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_serviceerror.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceError struct { + ActivityId *string `json:"activityId,omitempty"` + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_switchprotectionjobdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_switchprotectionjobdetails.go new file mode 100644 index 00000000000..31c8d2201f6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_switchprotectionjobdetails.go @@ -0,0 +1,42 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = SwitchProtectionJobDetails{} + +type SwitchProtectionJobDetails struct { + NewReplicationProtectedItemId *string `json:"newReplicationProtectedItemId,omitempty"` + + // Fields inherited from JobDetails + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` +} + +var _ json.Marshaler = SwitchProtectionJobDetails{} + +func (s SwitchProtectionJobDetails) MarshalJSON() ([]byte, error) { + type wrapper SwitchProtectionJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SwitchProtectionJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SwitchProtectionJobDetails: %+v", err) + } + decoded["instanceType"] = "SwitchProtectionJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SwitchProtectionJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_tasktypedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_tasktypedetails.go new file mode 100644 index 00000000000..fe8ac86fed8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_tasktypedetails.go @@ -0,0 +1,93 @@ +package replicationjobs + +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 TaskTypeDetails interface { +} + +// RawTaskTypeDetailsImpl 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 RawTaskTypeDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalTaskTypeDetailsImplementation(input []byte) (TaskTypeDetails, 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 TaskTypeDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AutomationRunbookTaskDetails") { + var out AutomationRunbookTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutomationRunbookTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ConsistencyCheckTaskDetails") { + var out ConsistencyCheckTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ConsistencyCheckTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "JobTaskDetails") { + var out JobTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into JobTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManualActionTaskDetails") { + var out ManualActionTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManualActionTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScriptActionTaskDetails") { + var out ScriptActionTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ScriptActionTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmNicUpdatesTaskDetails") { + var out VMNicUpdatesTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMNicUpdatesTaskDetails: %+v", err) + } + return out, nil + } + + out := RawTaskTypeDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_testfailoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_testfailoverjobdetails.go new file mode 100644 index 00000000000..63502161e0a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_testfailoverjobdetails.go @@ -0,0 +1,47 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = TestFailoverJobDetails{} + +type TestFailoverJobDetails struct { + Comments *string `json:"comments,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + TestFailoverStatus *string `json:"testFailoverStatus,omitempty"` + + // Fields inherited from JobDetails + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` +} + +var _ json.Marshaler = TestFailoverJobDetails{} + +func (s TestFailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper TestFailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TestFailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TestFailoverJobDetails: %+v", err) + } + decoded["instanceType"] = "TestFailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TestFailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_virtualmachinetaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_virtualmachinetaskdetails.go new file mode 100644 index 00000000000..42726d08363 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_virtualmachinetaskdetails.go @@ -0,0 +1,43 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = VirtualMachineTaskDetails{} + +type VirtualMachineTaskDetails struct { + SkippedReason *string `json:"skippedReason,omitempty"` + SkippedReasonString *string `json:"skippedReasonString,omitempty"` + + // Fields inherited from JobTaskDetails + JobTask *JobEntity `json:"jobTask,omitempty"` +} + +var _ json.Marshaler = VirtualMachineTaskDetails{} + +func (s VirtualMachineTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper VirtualMachineTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VirtualMachineTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VirtualMachineTaskDetails: %+v", err) + } + decoded["instanceType"] = "VirtualMachineTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VirtualMachineTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_vmnicupdatestaskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_vmnicupdatestaskdetails.go new file mode 100644 index 00000000000..ea5fa8cb61a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/model_vmnicupdatestaskdetails.go @@ -0,0 +1,43 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = VMNicUpdatesTaskDetails{} + +type VMNicUpdatesTaskDetails struct { + Name *string `json:"name,omitempty"` + NicId *string `json:"nicId,omitempty"` + VMId *string `json:"vmId,omitempty"` + + // Fields inherited from TaskTypeDetails +} + +var _ json.Marshaler = VMNicUpdatesTaskDetails{} + +func (s VMNicUpdatesTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper VMNicUpdatesTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMNicUpdatesTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMNicUpdatesTaskDetails: %+v", err) + } + decoded["instanceType"] = "VmNicUpdatesTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMNicUpdatesTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/predicates.go new file mode 100644 index 00000000000..840f78ec8e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/predicates.go @@ -0,0 +1,32 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p JobOperationPredicate) Matches(input Job) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationjobs/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/version.go new file mode 100644 index 00000000000..77eb66a25f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationjobs/version.go @@ -0,0 +1,12 @@ +package replicationjobs + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationjobs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/README.md new file mode 100644 index 00000000000..f4e0c2bcde9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks` Documentation + +The `replicationlogicalnetworks` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks" +``` + + +### Client Initialization + +```go +client := replicationlogicalnetworks.NewReplicationLogicalNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationLogicalNetworksClient.Get` + +```go +ctx := context.TODO() +id := replicationlogicalnetworks.NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationLogicalNetworkValue") + +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: `ReplicationLogicalNetworksClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationlogicalnetworks.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/client.go new file mode 100644 index 00000000000..ee0248503a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/client.go @@ -0,0 +1,26 @@ +package replicationlogicalnetworks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationLogicalNetworksClient struct { + Client *resourcemanager.Client +} + +func NewReplicationLogicalNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationLogicalNetworksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationlogicalnetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationLogicalNetworksClient: %+v", err) + } + + return &ReplicationLogicalNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationfabric.go new file mode 100644 index 00000000000..f410d538078 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationfabric.go @@ -0,0 +1,134 @@ +package replicationlogicalnetworks + +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 = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationfabric_test.go new file mode 100644 index 00000000000..4e9c9ba34e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationlogicalnetworks + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go new file mode 100644 index 00000000000..d580d0b1e31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go @@ -0,0 +1,143 @@ +package replicationlogicalnetworks + +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 = &ReplicationLogicalNetworkId{} + +// ReplicationLogicalNetworkId is a struct representing the Resource ID for a Replication Logical Network +type ReplicationLogicalNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationLogicalNetworkName string +} + +// NewReplicationLogicalNetworkID returns a new ReplicationLogicalNetworkId struct +func NewReplicationLogicalNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationLogicalNetworkName string) ReplicationLogicalNetworkId { + return ReplicationLogicalNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationLogicalNetworkName: replicationLogicalNetworkName, + } +} + +// ParseReplicationLogicalNetworkID parses 'input' into a ReplicationLogicalNetworkId +func ParseReplicationLogicalNetworkID(input string) (*ReplicationLogicalNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationLogicalNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationLogicalNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationLogicalNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationLogicalNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationLogicalNetworkIDInsensitively(input string) (*ReplicationLogicalNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationLogicalNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationLogicalNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationLogicalNetworkId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationLogicalNetworkName, ok = input.Parsed["replicationLogicalNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationLogicalNetworkName", input) + } + + return nil +} + +// ValidateReplicationLogicalNetworkID checks that 'input' can be parsed as a Replication Logical Network ID +func ValidateReplicationLogicalNetworkID(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 := ParseReplicationLogicalNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Logical Network ID +func (id ReplicationLogicalNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationLogicalNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationLogicalNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Logical Network ID +func (id ReplicationLogicalNetworkId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationLogicalNetworks", "replicationLogicalNetworks", "replicationLogicalNetworks"), + resourceids.UserSpecifiedSegment("replicationLogicalNetworkName", "replicationLogicalNetworkValue"), + } +} + +// String returns a human-readable description of this Replication Logical Network ID +func (id ReplicationLogicalNetworkId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Logical Network Name: %q", id.ReplicationLogicalNetworkName), + } + return fmt.Sprintf("Replication Logical Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go new file mode 100644 index 00000000000..ff72dcff7bb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go @@ -0,0 +1,372 @@ +package replicationlogicalnetworks + +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 = &ReplicationLogicalNetworkId{} + +func TestNewReplicationLogicalNetworkID(t *testing.T) { + id := NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationLogicalNetworkValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationLogicalNetworkName != "replicationLogicalNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationLogicalNetworkName'", id.ReplicationLogicalNetworkName, "replicationLogicalNetworkValue") + } +} + +func TestFormatReplicationLogicalNetworkID(t *testing.T) { + actual := NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationLogicalNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationLogicalNetworks/replicationLogicalNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationLogicalNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationLogicalNetworkId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationLogicalNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationLogicalNetworks/replicationLogicalNetworkValue", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationLogicalNetworkName: "replicationLogicalNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationLogicalNetworks/replicationLogicalNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationLogicalNetworkID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationLogicalNetworkName != v.Expected.ReplicationLogicalNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationLogicalNetworkName", v.Expected.ReplicationLogicalNetworkName, actual.ReplicationLogicalNetworkName) + } + + } +} + +func TestParseReplicationLogicalNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationLogicalNetworkId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationLogicalNetworks", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnLoGiCaLnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationLogicalNetworks/replicationLogicalNetworkValue", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationLogicalNetworkName: "replicationLogicalNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationLogicalNetworks/replicationLogicalNetworkValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnLoGiCaLnEtWoRkS/rEpLiCaTiOnLoGiCaLnEtWoRkVaLuE", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationLogicalNetworkName: "rEpLiCaTiOnLoGiCaLnEtWoRkVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnLoGiCaLnEtWoRkS/rEpLiCaTiOnLoGiCaLnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationLogicalNetworkIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationLogicalNetworkName != v.Expected.ReplicationLogicalNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationLogicalNetworkName", v.Expected.ReplicationLogicalNetworkName, actual.ReplicationLogicalNetworkName) + } + + } +} + +func TestSegmentsForReplicationLogicalNetworkId(t *testing.T) { + segments := ReplicationLogicalNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationLogicalNetworkId 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/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/method_get.go new file mode 100644 index 00000000000..3c3501c14bf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/method_get.go @@ -0,0 +1,51 @@ +package replicationlogicalnetworks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogicalNetwork +} + +// Get ... +func (c ReplicationLogicalNetworksClient) Get(ctx context.Context, id ReplicationLogicalNetworkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..c036fb97542 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go @@ -0,0 +1,91 @@ +package replicationlogicalnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogicalNetwork +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogicalNetwork +} + +// ListByReplicationFabrics ... +func (c ReplicationLogicalNetworksClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationLogicalNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LogicalNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationLogicalNetworksClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, LogicalNetworkOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationLogicalNetworksClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate LogicalNetworkOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]LogicalNetwork, 0) + + resp, err := c.ListByReplicationFabrics(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/model_logicalnetwork.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/model_logicalnetwork.go new file mode 100644 index 00000000000..957182ab3db --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/model_logicalnetwork.go @@ -0,0 +1,12 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetwork struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LogicalNetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/model_logicalnetworkproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/model_logicalnetworkproperties.go new file mode 100644 index 00000000000..2200c344760 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/model_logicalnetworkproperties.go @@ -0,0 +1,11 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + LogicalNetworkDefinitionsStatus *string `json:"logicalNetworkDefinitionsStatus,omitempty"` + LogicalNetworkUsage *string `json:"logicalNetworkUsage,omitempty"` + NetworkVirtualizationStatus *string `json:"networkVirtualizationStatus,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/predicates.go new file mode 100644 index 00000000000..30e71a8f92c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/predicates.go @@ -0,0 +1,32 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p LogicalNetworkOperationPredicate) Matches(input LogicalNetwork) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/version.go new file mode 100644 index 00000000000..0be583e1363 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationlogicalnetworks/version.go @@ -0,0 +1,12 @@ +package replicationlogicalnetworks + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationlogicalnetworks/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/README.md new file mode 100644 index 00000000000..ab039b3ca5e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/README.md @@ -0,0 +1,218 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems` Documentation + +The `replicationmigrationitems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems" +``` + + +### Client Initialization + +```go +client := replicationmigrationitems.NewReplicationMigrationItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Create` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +payload := replicationmigrationitems.EnableMigrationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Delete` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +if err := client.DeleteThenPoll(ctx, id, replicationmigrationitems.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +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: `ReplicationMigrationItemsClient.List` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, replicationmigrationitems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationmigrationitems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id, replicationmigrationitems.DefaultListByReplicationProtectionContainersOperationOptions())` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id, replicationmigrationitems.DefaultListByReplicationProtectionContainersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Migrate` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +payload := replicationmigrationitems.MigrateInput{ + // ... +} + + +if err := client.MigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.PauseReplication` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +payload := replicationmigrationitems.PauseReplicationInput{ + // ... +} + + +if err := client.PauseReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.ResumeReplication` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +payload := replicationmigrationitems.ResumeReplicationInput{ + // ... +} + + +if err := client.ResumeReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Resync` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +payload := replicationmigrationitems.ResyncInput{ + // ... +} + + +if err := client.ResyncThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.TestMigrate` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +payload := replicationmigrationitems.TestMigrateInput{ + // ... +} + + +if err := client.TestMigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.TestMigrateCleanup` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +payload := replicationmigrationitems.TestMigrateCleanupInput{ + // ... +} + + +if err := client.TestMigrateCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Update` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + +payload := replicationmigrationitems.UpdateMigrationItemInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/client.go new file mode 100644 index 00000000000..407c7fd8d2c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/client.go @@ -0,0 +1,26 @@ +package replicationmigrationitems + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationMigrationItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationMigrationItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationMigrationItemsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationmigrationitems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationMigrationItemsClient: %+v", err) + } + + return &ReplicationMigrationItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/constants.go new file mode 100644 index 00000000000..4b214b27211 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/constants.go @@ -0,0 +1,560 @@ +package replicationmigrationitems + +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 DiskAccountType string + +const ( + DiskAccountTypePremiumLRS DiskAccountType = "Premium_LRS" + DiskAccountTypeStandardLRS DiskAccountType = "Standard_LRS" + DiskAccountTypeStandardSSDLRS DiskAccountType = "StandardSSD_LRS" +) + +func PossibleValuesForDiskAccountType() []string { + return []string{ + string(DiskAccountTypePremiumLRS), + string(DiskAccountTypeStandardLRS), + string(DiskAccountTypeStandardSSDLRS), + } +} + +func (s *DiskAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskAccountType(input string) (*DiskAccountType, error) { + vals := map[string]DiskAccountType{ + "premium_lrs": DiskAccountTypePremiumLRS, + "standard_lrs": DiskAccountTypeStandardLRS, + "standardssd_lrs": DiskAccountTypeStandardSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskAccountType(input) + return &out, nil +} + +type EthernetAddressType string + +const ( + EthernetAddressTypeDynamic EthernetAddressType = "Dynamic" + EthernetAddressTypeStatic EthernetAddressType = "Static" +) + +func PossibleValuesForEthernetAddressType() []string { + return []string{ + string(EthernetAddressTypeDynamic), + string(EthernetAddressTypeStatic), + } +} + +func (s *EthernetAddressType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEthernetAddressType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEthernetAddressType(input string) (*EthernetAddressType, error) { + vals := map[string]EthernetAddressType{ + "dynamic": EthernetAddressTypeDynamic, + "static": EthernetAddressTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EthernetAddressType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type LicenseType string + +const ( + LicenseTypeNoLicenseType LicenseType = "NoLicenseType" + LicenseTypeNotSpecified LicenseType = "NotSpecified" + LicenseTypeWindowsServer LicenseType = "WindowsServer" +) + +func PossibleValuesForLicenseType() []string { + return []string{ + string(LicenseTypeNoLicenseType), + string(LicenseTypeNotSpecified), + string(LicenseTypeWindowsServer), + } +} + +func (s *LicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseType(input string) (*LicenseType, error) { + vals := map[string]LicenseType{ + "nolicensetype": LicenseTypeNoLicenseType, + "notspecified": LicenseTypeNotSpecified, + "windowsserver": LicenseTypeWindowsServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseType(input) + return &out, nil +} + +type MigrationItemOperation string + +const ( + MigrationItemOperationDisableMigration MigrationItemOperation = "DisableMigration" + MigrationItemOperationMigrate MigrationItemOperation = "Migrate" + MigrationItemOperationPauseReplication MigrationItemOperation = "PauseReplication" + MigrationItemOperationResumeReplication MigrationItemOperation = "ResumeReplication" + MigrationItemOperationStartResync MigrationItemOperation = "StartResync" + MigrationItemOperationTestMigrate MigrationItemOperation = "TestMigrate" + MigrationItemOperationTestMigrateCleanup MigrationItemOperation = "TestMigrateCleanup" +) + +func PossibleValuesForMigrationItemOperation() []string { + return []string{ + string(MigrationItemOperationDisableMigration), + string(MigrationItemOperationMigrate), + string(MigrationItemOperationPauseReplication), + string(MigrationItemOperationResumeReplication), + string(MigrationItemOperationStartResync), + string(MigrationItemOperationTestMigrate), + string(MigrationItemOperationTestMigrateCleanup), + } +} + +func (s *MigrationItemOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationItemOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationItemOperation(input string) (*MigrationItemOperation, error) { + vals := map[string]MigrationItemOperation{ + "disablemigration": MigrationItemOperationDisableMigration, + "migrate": MigrationItemOperationMigrate, + "pausereplication": MigrationItemOperationPauseReplication, + "resumereplication": MigrationItemOperationResumeReplication, + "startresync": MigrationItemOperationStartResync, + "testmigrate": MigrationItemOperationTestMigrate, + "testmigratecleanup": MigrationItemOperationTestMigrateCleanup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationItemOperation(input) + return &out, nil +} + +type MigrationState string + +const ( + MigrationStateDisableMigrationFailed MigrationState = "DisableMigrationFailed" + MigrationStateDisableMigrationInProgress MigrationState = "DisableMigrationInProgress" + MigrationStateEnableMigrationFailed MigrationState = "EnableMigrationFailed" + MigrationStateEnableMigrationInProgress MigrationState = "EnableMigrationInProgress" + MigrationStateInitialSeedingFailed MigrationState = "InitialSeedingFailed" + MigrationStateInitialSeedingInProgress MigrationState = "InitialSeedingInProgress" + MigrationStateMigrationCompletedWithInformation MigrationState = "MigrationCompletedWithInformation" + MigrationStateMigrationFailed MigrationState = "MigrationFailed" + MigrationStateMigrationInProgress MigrationState = "MigrationInProgress" + MigrationStateMigrationPartiallySucceeded MigrationState = "MigrationPartiallySucceeded" + MigrationStateMigrationSucceeded MigrationState = "MigrationSucceeded" + MigrationStateNone MigrationState = "None" + MigrationStateProtectionSuspended MigrationState = "ProtectionSuspended" + MigrationStateReplicating MigrationState = "Replicating" + MigrationStateResumeInProgress MigrationState = "ResumeInProgress" + MigrationStateResumeInitiated MigrationState = "ResumeInitiated" + MigrationStateSuspendingProtection MigrationState = "SuspendingProtection" +) + +func PossibleValuesForMigrationState() []string { + return []string{ + string(MigrationStateDisableMigrationFailed), + string(MigrationStateDisableMigrationInProgress), + string(MigrationStateEnableMigrationFailed), + string(MigrationStateEnableMigrationInProgress), + string(MigrationStateInitialSeedingFailed), + string(MigrationStateInitialSeedingInProgress), + string(MigrationStateMigrationCompletedWithInformation), + string(MigrationStateMigrationFailed), + string(MigrationStateMigrationInProgress), + string(MigrationStateMigrationPartiallySucceeded), + string(MigrationStateMigrationSucceeded), + string(MigrationStateNone), + string(MigrationStateProtectionSuspended), + string(MigrationStateReplicating), + string(MigrationStateResumeInProgress), + string(MigrationStateResumeInitiated), + string(MigrationStateSuspendingProtection), + } +} + +func (s *MigrationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationState(input string) (*MigrationState, error) { + vals := map[string]MigrationState{ + "disablemigrationfailed": MigrationStateDisableMigrationFailed, + "disablemigrationinprogress": MigrationStateDisableMigrationInProgress, + "enablemigrationfailed": MigrationStateEnableMigrationFailed, + "enablemigrationinprogress": MigrationStateEnableMigrationInProgress, + "initialseedingfailed": MigrationStateInitialSeedingFailed, + "initialseedinginprogress": MigrationStateInitialSeedingInProgress, + "migrationcompletedwithinformation": MigrationStateMigrationCompletedWithInformation, + "migrationfailed": MigrationStateMigrationFailed, + "migrationinprogress": MigrationStateMigrationInProgress, + "migrationpartiallysucceeded": MigrationStateMigrationPartiallySucceeded, + "migrationsucceeded": MigrationStateMigrationSucceeded, + "none": MigrationStateNone, + "protectionsuspended": MigrationStateProtectionSuspended, + "replicating": MigrationStateReplicating, + "resumeinprogress": MigrationStateResumeInProgress, + "resumeinitiated": MigrationStateResumeInitiated, + "suspendingprotection": MigrationStateSuspendingProtection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationState(input) + return &out, nil +} + +type ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type ResyncState string + +const ( + ResyncStateNone ResyncState = "None" + ResyncStatePreparedForResynchronization ResyncState = "PreparedForResynchronization" + ResyncStateStartedResynchronization ResyncState = "StartedResynchronization" +) + +func PossibleValuesForResyncState() []string { + return []string{ + string(ResyncStateNone), + string(ResyncStatePreparedForResynchronization), + string(ResyncStateStartedResynchronization), + } +} + +func (s *ResyncState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResyncState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResyncState(input string) (*ResyncState, error) { + vals := map[string]ResyncState{ + "none": ResyncStateNone, + "preparedforresynchronization": ResyncStatePreparedForResynchronization, + "startedresynchronization": ResyncStateStartedResynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResyncState(input) + return &out, nil +} + +type SecurityType string + +const ( + SecurityTypeConfidentialVM SecurityType = "ConfidentialVM" + SecurityTypeNone SecurityType = "None" + SecurityTypeTrustedLaunch SecurityType = "TrustedLaunch" +) + +func PossibleValuesForSecurityType() []string { + return []string{ + string(SecurityTypeConfidentialVM), + string(SecurityTypeNone), + string(SecurityTypeTrustedLaunch), + } +} + +func (s *SecurityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityType(input string) (*SecurityType, error) { + vals := map[string]SecurityType{ + "confidentialvm": SecurityTypeConfidentialVM, + "none": SecurityTypeNone, + "trustedlaunch": SecurityTypeTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityType(input) + return &out, nil +} + +type SqlServerLicenseType string + +const ( + SqlServerLicenseTypeAHUB SqlServerLicenseType = "AHUB" + SqlServerLicenseTypeNoLicenseType SqlServerLicenseType = "NoLicenseType" + SqlServerLicenseTypeNotSpecified SqlServerLicenseType = "NotSpecified" + SqlServerLicenseTypePAYG SqlServerLicenseType = "PAYG" +) + +func PossibleValuesForSqlServerLicenseType() []string { + return []string{ + string(SqlServerLicenseTypeAHUB), + string(SqlServerLicenseTypeNoLicenseType), + string(SqlServerLicenseTypeNotSpecified), + string(SqlServerLicenseTypePAYG), + } +} + +func (s *SqlServerLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlServerLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlServerLicenseType(input string) (*SqlServerLicenseType, error) { + vals := map[string]SqlServerLicenseType{ + "ahub": SqlServerLicenseTypeAHUB, + "nolicensetype": SqlServerLicenseTypeNoLicenseType, + "notspecified": SqlServerLicenseTypeNotSpecified, + "payg": SqlServerLicenseTypePAYG, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlServerLicenseType(input) + return &out, nil +} + +type TestMigrationState string + +const ( + TestMigrationStateNone TestMigrationState = "None" + TestMigrationStateTestMigrationCleanupInProgress TestMigrationState = "TestMigrationCleanupInProgress" + TestMigrationStateTestMigrationCompletedWithInformation TestMigrationState = "TestMigrationCompletedWithInformation" + TestMigrationStateTestMigrationFailed TestMigrationState = "TestMigrationFailed" + TestMigrationStateTestMigrationInProgress TestMigrationState = "TestMigrationInProgress" + TestMigrationStateTestMigrationPartiallySucceeded TestMigrationState = "TestMigrationPartiallySucceeded" + TestMigrationStateTestMigrationSucceeded TestMigrationState = "TestMigrationSucceeded" +) + +func PossibleValuesForTestMigrationState() []string { + return []string{ + string(TestMigrationStateNone), + string(TestMigrationStateTestMigrationCleanupInProgress), + string(TestMigrationStateTestMigrationCompletedWithInformation), + string(TestMigrationStateTestMigrationFailed), + string(TestMigrationStateTestMigrationInProgress), + string(TestMigrationStateTestMigrationPartiallySucceeded), + string(TestMigrationStateTestMigrationSucceeded), + } +} + +func (s *TestMigrationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTestMigrationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTestMigrationState(input string) (*TestMigrationState, error) { + vals := map[string]TestMigrationState{ + "none": TestMigrationStateNone, + "testmigrationcleanupinprogress": TestMigrationStateTestMigrationCleanupInProgress, + "testmigrationcompletedwithinformation": TestMigrationStateTestMigrationCompletedWithInformation, + "testmigrationfailed": TestMigrationStateTestMigrationFailed, + "testmigrationinprogress": TestMigrationStateTestMigrationInProgress, + "testmigrationpartiallysucceeded": TestMigrationStateTestMigrationPartiallySucceeded, + "testmigrationsucceeded": TestMigrationStateTestMigrationSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TestMigrationState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationmigrationitem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationmigrationitem.go new file mode 100644 index 00000000000..7df9bad62f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationmigrationitem.go @@ -0,0 +1,152 @@ +package replicationmigrationitems + +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 = &ReplicationMigrationItemId{} + +// ReplicationMigrationItemId is a struct representing the Resource ID for a Replication Migration Item +type ReplicationMigrationItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string +} + +// NewReplicationMigrationItemID returns a new ReplicationMigrationItemId struct +func NewReplicationMigrationItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string) ReplicationMigrationItemId { + return ReplicationMigrationItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + } +} + +// ParseReplicationMigrationItemID parses 'input' into a ReplicationMigrationItemId +func ParseReplicationMigrationItemID(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationMigrationItemIDInsensitively parses 'input' case-insensitively into a ReplicationMigrationItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationMigrationItemIDInsensitively(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationMigrationItemId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + return nil +} + +// ValidateReplicationMigrationItemID checks that 'input' can be parsed as a Replication Migration Item ID +func ValidateReplicationMigrationItemID(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 := ParseReplicationMigrationItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Migration Item ID +func (id ReplicationMigrationItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Migration Item ID +func (id ReplicationMigrationItemId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemValue"), + } +} + +// String returns a human-readable description of this Replication Migration Item ID +func (id ReplicationMigrationItemId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + } + return fmt.Sprintf("Replication Migration Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationmigrationitem_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationmigrationitem_test.go new file mode 100644 index 00000000000..e47af22ad40 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationmigrationitem_test.go @@ -0,0 +1,417 @@ +package replicationmigrationitems + +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 = &ReplicationMigrationItemId{} + +func TestNewReplicationMigrationItemID(t *testing.T) { + id := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemValue") + } +} + +func TestFormatReplicationMigrationItemID(t *testing.T) { + actual := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationMigrationItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationMigrationItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationMigrationItemName: "replicationMigrationItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestParseReplicationMigrationItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationMigrationItemName: "replicationMigrationItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationMigrationItems/replicationMigrationItemValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMvAlUe", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestSegmentsForReplicationMigrationItemId(t *testing.T) { + segments := ReplicationMigrationItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationMigrationItemId 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/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..c9c3607ba49 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationprotectioncontainer.go @@ -0,0 +1,143 @@ +package replicationmigrationitems + +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 = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..7b26ad25b4a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationmigrationitems + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_vault.go new file mode 100644 index 00000000000..368a5781193 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_vault.go @@ -0,0 +1,125 @@ +package replicationmigrationitems + +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/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_vault_test.go new file mode 100644 index 00000000000..774422911de --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationmigrationitems + +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/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_create.go new file mode 100644 index 00000000000..8bab8c5aa6d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_create.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Create ... +func (c ReplicationMigrationItemsClient) Create(ctx context.Context, id ReplicationMigrationItemId, input EnableMigrationInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationMigrationItemsClient) CreateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input EnableMigrationInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_delete.go new file mode 100644 index 00000000000..ba867def8dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_delete.go @@ -0,0 +1,98 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteOption *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteOption != nil { + out.Append("deleteOption", fmt.Sprintf("%v", *o.DeleteOption)) + } + return &out +} + +// Delete ... +func (c ReplicationMigrationItemsClient) Delete(ctx context.Context, id ReplicationMigrationItemId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationMigrationItemsClient) DeleteThenPoll(ctx context.Context, id ReplicationMigrationItemId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_get.go new file mode 100644 index 00000000000..f8d7c9fb166 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_get.go @@ -0,0 +1,51 @@ +package replicationmigrationitems + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Get ... +func (c ReplicationMigrationItemsClient) Get(ctx context.Context, id ReplicationMigrationItemId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_list.go new file mode 100644 index 00000000000..4f595b75fe2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_list.go @@ -0,0 +1,127 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationItem +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationItem +} + +type ListOperationOptions struct { + Filter *string + SkipToken *string + TakeToken *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + return &out +} + +// List ... +func (c ReplicationMigrationItemsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationMigrationItems", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MigrationItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationMigrationItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, MigrationItemOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationMigrationItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate MigrationItemOperationPredicate) (result ListCompleteResult, err error) { + items := make([]MigrationItem, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..6a2fc901442 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,127 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationItem +} + +type ListByReplicationProtectionContainersOperationOptions struct { + Filter *string + SkipToken *string + TakeToken *string +} + +func DefaultListByReplicationProtectionContainersOperationOptions() ListByReplicationProtectionContainersOperationOptions { + return ListByReplicationProtectionContainersOperationOptions{} +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + return &out +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationMigrationItems", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MigrationItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, options, MigrationItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions, predicate MigrationItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]MigrationItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_migrate.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_migrate.go new file mode 100644 index 00000000000..39eeccdea24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_migrate.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Migrate ... +func (c ReplicationMigrationItemsClient) Migrate(ctx context.Context, id ReplicationMigrationItemId, input MigrateInput) (result MigrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// MigrateThenPoll performs Migrate then polls until it's completed +func (c ReplicationMigrationItemsClient) MigrateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input MigrateInput) error { + result, err := c.Migrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Migrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Migrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_pausereplication.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_pausereplication.go new file mode 100644 index 00000000000..18b469af880 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_pausereplication.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PauseReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// PauseReplication ... +func (c ReplicationMigrationItemsClient) PauseReplication(ctx context.Context, id ReplicationMigrationItemId, input PauseReplicationInput) (result PauseReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/pauseReplication", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PauseReplicationThenPoll performs PauseReplication then polls until it's completed +func (c ReplicationMigrationItemsClient) PauseReplicationThenPoll(ctx context.Context, id ReplicationMigrationItemId, input PauseReplicationInput) error { + result, err := c.PauseReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PauseReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PauseReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_resumereplication.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_resumereplication.go new file mode 100644 index 00000000000..38d610dcc9f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_resumereplication.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// ResumeReplication ... +func (c ReplicationMigrationItemsClient) ResumeReplication(ctx context.Context, id ReplicationMigrationItemId, input ResumeReplicationInput) (result ResumeReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resumeReplication", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResumeReplicationThenPoll performs ResumeReplication then polls until it's completed +func (c ReplicationMigrationItemsClient) ResumeReplicationThenPoll(ctx context.Context, id ReplicationMigrationItemId, input ResumeReplicationInput) error { + result, err := c.ResumeReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResumeReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResumeReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_resync.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_resync.go new file mode 100644 index 00000000000..dd463cfd5a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_resync.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResyncOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Resync ... +func (c ReplicationMigrationItemsClient) Resync(ctx context.Context, id ReplicationMigrationItemId, input ResyncInput) (result ResyncOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResyncThenPoll performs Resync then polls until it's completed +func (c ReplicationMigrationItemsClient) ResyncThenPoll(ctx context.Context, id ReplicationMigrationItemId, input ResyncInput) error { + result, err := c.Resync(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Resync: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resync: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_testmigrate.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_testmigrate.go new file mode 100644 index 00000000000..998b9b6f304 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_testmigrate.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// TestMigrate ... +func (c ReplicationMigrationItemsClient) TestMigrate(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateInput) (result TestMigrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testMigrate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestMigrateThenPoll performs TestMigrate then polls until it's completed +func (c ReplicationMigrationItemsClient) TestMigrateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateInput) error { + result, err := c.TestMigrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestMigrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestMigrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_testmigratecleanup.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_testmigratecleanup.go new file mode 100644 index 00000000000..0d2c2032c31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_testmigratecleanup.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// TestMigrateCleanup ... +func (c ReplicationMigrationItemsClient) TestMigrateCleanup(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateCleanupInput) (result TestMigrateCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testMigrateCleanup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestMigrateCleanupThenPoll performs TestMigrateCleanup then polls until it's completed +func (c ReplicationMigrationItemsClient) TestMigrateCleanupThenPoll(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateCleanupInput) error { + result, err := c.TestMigrateCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestMigrateCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestMigrateCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_update.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_update.go new file mode 100644 index 00000000000..cb63d5a8133 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/method_update.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Update ... +func (c ReplicationMigrationItemsClient) Update(ctx context.Context, id ReplicationMigrationItemId, input UpdateMigrationItemInput) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ReplicationMigrationItemsClient) UpdateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input UpdateMigrationItemInput) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_appliancemonitoringdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_appliancemonitoringdetails.go new file mode 100644 index 00000000000..4fe6ced44c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_appliancemonitoringdetails.go @@ -0,0 +1,13 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceMonitoringDetails struct { + CpuDetails *ApplianceResourceDetails `json:"cpuDetails,omitempty"` + DatastoreSnapshot *[]DataStoreUtilizationDetails `json:"datastoreSnapshot,omitempty"` + DisksReplicationDetails *ApplianceResourceDetails `json:"disksReplicationDetails,omitempty"` + EsxiNfcBuffer *ApplianceResourceDetails `json:"esxiNfcBuffer,omitempty"` + NetworkBandwidth *ApplianceResourceDetails `json:"networkBandwidth,omitempty"` + RamDetails *ApplianceResourceDetails `json:"ramDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_applianceresourcedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_applianceresourcedetails.go new file mode 100644 index 00000000000..d2d7263c748 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_applianceresourcedetails.go @@ -0,0 +1,11 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceResourceDetails struct { + Capacity *int64 `json:"capacity,omitempty"` + ProcessUtilization *float64 `json:"processUtilization,omitempty"` + Status *string `json:"status,omitempty"` + TotalUtilization *float64 `json:"totalUtilization,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_criticaljobhistorydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_criticaljobhistorydetails.go new file mode 100644 index 00000000000..cbaf060f779 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_criticaljobhistorydetails.go @@ -0,0 +1,29 @@ +package replicationmigrationitems + +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 CriticalJobHistoryDetails struct { + JobId *string `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CriticalJobHistoryDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CriticalJobHistoryDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_currentjobdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_currentjobdetails.go new file mode 100644 index 00000000000..6461ea7fe4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_currentjobdetails.go @@ -0,0 +1,28 @@ +package replicationmigrationitems + +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 CurrentJobDetails struct { + JobId *string `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentJobDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentJobDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_datastoreutilizationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_datastoreutilizationdetails.go new file mode 100644 index 00000000000..21df088d5b6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_datastoreutilizationdetails.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataStoreUtilizationDetails struct { + DataStoreName *string `json:"dataStoreName,omitempty"` + TotalSnapshotsCreated *int64 `json:"totalSnapshotsCreated,omitempty"` + TotalSnapshotsSupported *int64 `json:"totalSnapshotsSupported,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationinput.go new file mode 100644 index 00000000000..eeb46d6566e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnableMigrationInput struct { + Properties EnableMigrationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationinputproperties.go new file mode 100644 index 00000000000..49ca92b996e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationinputproperties.go @@ -0,0 +1,40 @@ +package replicationmigrationitems + +import ( + "encoding/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 EnableMigrationInputProperties struct { + PolicyId string `json:"policyId"` + ProviderSpecificDetails EnableMigrationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &EnableMigrationInputProperties{} + +func (s *EnableMigrationInputProperties) UnmarshalJSON(bytes []byte) error { + type alias EnableMigrationInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into EnableMigrationInputProperties: %+v", err) + } + + s.PolicyId = decoded.PolicyId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EnableMigrationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalEnableMigrationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EnableMigrationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go new file mode 100644 index 00000000000..73cd5957a66 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +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 EnableMigrationProviderSpecificInput interface { +} + +// RawEnableMigrationProviderSpecificInputImpl 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 RawEnableMigrationProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalEnableMigrationProviderSpecificInputImplementation(input []byte) (EnableMigrationProviderSpecificInput, 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 EnableMigrationProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtEnableMigrationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtEnableMigrationInput: %+v", err) + } + return out, nil + } + + out := RawEnableMigrationProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_gatewayoperationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_gatewayoperationdetails.go new file mode 100644 index 00000000000..b0cbbc52f12 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_gatewayoperationdetails.go @@ -0,0 +1,15 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayOperationDetails struct { + DataStores *[]string `json:"dataStores,omitempty"` + HostName *string `json:"hostName,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + State *string `json:"state,omitempty"` + TimeElapsed *int64 `json:"timeElapsed,omitempty"` + TimeRemaining *int64 `json:"timeRemaining,omitempty"` + UploadSpeed *int64 `json:"uploadSpeed,omitempty"` + VMwareReadThroughput *int64 `json:"vmwareReadThroughput,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_healtherror.go new file mode 100644 index 00000000000..bd011f2be40 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationmigrationitems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_innerhealtherror.go new file mode 100644 index 00000000000..57850e37e2e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationmigrationitems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateinput.go new file mode 100644 index 00000000000..64530958cea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateInput struct { + Properties MigrateInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateinputproperties.go new file mode 100644 index 00000000000..3b1bf018068 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateinputproperties.go @@ -0,0 +1,32 @@ +package replicationmigrationitems + +import ( + "encoding/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 MigrateInputProperties struct { + ProviderSpecificDetails MigrateProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &MigrateInputProperties{} + +func (s *MigrateInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MigrateInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalMigrateProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'MigrateInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateproviderspecificinput.go new file mode 100644 index 00000000000..73a6bcd8bc7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrateproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +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 MigrateProviderSpecificInput interface { +} + +// RawMigrateProviderSpecificInputImpl 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 RawMigrateProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalMigrateProviderSpecificInputImplementation(input []byte) (MigrateProviderSpecificInput, 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 MigrateProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtMigrateInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtMigrateInput: %+v", err) + } + return out, nil + } + + out := RawMigrateProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationitem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationitem.go new file mode 100644 index 00000000000..42cd0fcb04e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationitem.go @@ -0,0 +1,12 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrationItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationitemproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationitemproperties.go new file mode 100644 index 00000000000..76e077d7bde --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationitemproperties.go @@ -0,0 +1,103 @@ +package replicationmigrationitems + +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. + +type MigrationItemProperties struct { + AllowedOperations *[]MigrationItemOperation `json:"allowedOperations,omitempty"` + CriticalJobHistory *[]CriticalJobHistoryDetails `json:"criticalJobHistory,omitempty"` + CurrentJob *CurrentJobDetails `json:"currentJob,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastMigrationStatus *string `json:"lastMigrationStatus,omitempty"` + LastMigrationTime *string `json:"lastMigrationTime,omitempty"` + LastTestMigrationStatus *string `json:"lastTestMigrationStatus,omitempty"` + LastTestMigrationTime *string `json:"lastTestMigrationTime,omitempty"` + MachineName *string `json:"machineName,omitempty"` + MigrationState *MigrationState `json:"migrationState,omitempty"` + MigrationStateDescription *string `json:"migrationStateDescription,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificDetails MigrationProviderSpecificSettings `json:"providerSpecificDetails"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationStatus *string `json:"replicationStatus,omitempty"` + TestMigrateState *TestMigrationState `json:"testMigrateState,omitempty"` + TestMigrateStateDescription *string `json:"testMigrateStateDescription,omitempty"` +} + +func (o *MigrationItemProperties) GetLastMigrationTimeAsTime() (*time.Time, error) { + if o.LastMigrationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastMigrationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationItemProperties) SetLastMigrationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastMigrationTime = &formatted +} + +func (o *MigrationItemProperties) GetLastTestMigrationTimeAsTime() (*time.Time, error) { + if o.LastTestMigrationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastTestMigrationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationItemProperties) SetLastTestMigrationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastTestMigrationTime = &formatted +} + +var _ json.Unmarshaler = &MigrationItemProperties{} + +func (s *MigrationItemProperties) UnmarshalJSON(bytes []byte) error { + type alias MigrationItemProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into MigrationItemProperties: %+v", err) + } + + s.AllowedOperations = decoded.AllowedOperations + s.CriticalJobHistory = decoded.CriticalJobHistory + s.CurrentJob = decoded.CurrentJob + s.EventCorrelationId = decoded.EventCorrelationId + s.Health = decoded.Health + s.HealthErrors = decoded.HealthErrors + s.LastMigrationStatus = decoded.LastMigrationStatus + s.LastMigrationTime = decoded.LastMigrationTime + s.LastTestMigrationStatus = decoded.LastTestMigrationStatus + s.LastTestMigrationTime = decoded.LastTestMigrationTime + s.MachineName = decoded.MachineName + s.MigrationState = decoded.MigrationState + s.MigrationStateDescription = decoded.MigrationStateDescription + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationStatus = decoded.ReplicationStatus + s.TestMigrateState = decoded.TestMigrateState + s.TestMigrateStateDescription = decoded.TestMigrateStateDescription + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MigrationItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalMigrationProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'MigrationItemProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationproviderspecificsettings.go new file mode 100644 index 00000000000..a6a75af2819 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_migrationproviderspecificsettings.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +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 MigrationProviderSpecificSettings interface { +} + +// RawMigrationProviderSpecificSettingsImpl 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 RawMigrationProviderSpecificSettingsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalMigrationProviderSpecificSettingsImplementation(input []byte) (MigrationProviderSpecificSettings, 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 MigrationProviderSpecificSettings into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtMigrationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtMigrationDetails: %+v", err) + } + return out, nil + } + + out := RawMigrationProviderSpecificSettingsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_pausereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_pausereplicationinput.go new file mode 100644 index 00000000000..9e6108005ed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_pausereplicationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PauseReplicationInput struct { + Properties PauseReplicationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_pausereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_pausereplicationinputproperties.go new file mode 100644 index 00000000000..67b7a7a192c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_pausereplicationinputproperties.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PauseReplicationInputProperties struct { + InstanceType string `json:"instanceType"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationinput.go new file mode 100644 index 00000000000..fb4429f5eac --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeReplicationInput struct { + Properties ResumeReplicationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationinputproperties.go new file mode 100644 index 00000000000..2f4cf233728 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationinputproperties.go @@ -0,0 +1,32 @@ +package replicationmigrationitems + +import ( + "encoding/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 ResumeReplicationInputProperties struct { + ProviderSpecificDetails ResumeReplicationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ResumeReplicationInputProperties{} + +func (s *ResumeReplicationInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ResumeReplicationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalResumeReplicationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ResumeReplicationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go new file mode 100644 index 00000000000..d2fc33ca6a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +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 ResumeReplicationProviderSpecificInput interface { +} + +// RawResumeReplicationProviderSpecificInputImpl 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 RawResumeReplicationProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalResumeReplicationProviderSpecificInputImplementation(input []byte) (ResumeReplicationProviderSpecificInput, 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 ResumeReplicationProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtResumeReplicationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtResumeReplicationInput: %+v", err) + } + return out, nil + } + + out := RawResumeReplicationProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncinput.go new file mode 100644 index 00000000000..e680c11686e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResyncInput struct { + Properties ResyncInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncinputproperties.go new file mode 100644 index 00000000000..a440510e3b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncinputproperties.go @@ -0,0 +1,32 @@ +package replicationmigrationitems + +import ( + "encoding/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 ResyncInputProperties struct { + ProviderSpecificDetails ResyncProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ResyncInputProperties{} + +func (s *ResyncInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ResyncInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalResyncProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ResyncInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncproviderspecificinput.go new file mode 100644 index 00000000000..e07bca951f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_resyncproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +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 ResyncProviderSpecificInput interface { +} + +// RawResyncProviderSpecificInputImpl 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 RawResyncProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalResyncProviderSpecificInputImplementation(input []byte) (ResyncProviderSpecificInput, 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 ResyncProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtResyncInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtResyncInput: %+v", err) + } + return out, nil + } + + out := RawResyncProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigratecleanupinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigratecleanupinput.go new file mode 100644 index 00000000000..15890ac313a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigratecleanupinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateCleanupInput struct { + Properties TestMigrateCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go new file mode 100644 index 00000000000..a7ac0568f76 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateinput.go new file mode 100644 index 00000000000..cc8da4dbada --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateInput struct { + Properties TestMigrateInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateinputproperties.go new file mode 100644 index 00000000000..5453572f37d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateinputproperties.go @@ -0,0 +1,32 @@ +package replicationmigrationitems + +import ( + "encoding/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 TestMigrateInputProperties struct { + ProviderSpecificDetails TestMigrateProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &TestMigrateInputProperties{} + +func (s *TestMigrateInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TestMigrateInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalTestMigrateProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'TestMigrateInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go new file mode 100644 index 00000000000..16161329aca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +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 TestMigrateProviderSpecificInput interface { +} + +// RawTestMigrateProviderSpecificInputImpl 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 RawTestMigrateProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalTestMigrateProviderSpecificInputImplementation(input []byte) (TestMigrateProviderSpecificInput, 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 TestMigrateProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtTestMigrateInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtTestMigrateInput: %+v", err) + } + return out, nil + } + + out := RawTestMigrateProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationiteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationiteminput.go new file mode 100644 index 00000000000..3a41aab1339 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationiteminput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMigrationItemInput struct { + Properties *UpdateMigrationItemInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go new file mode 100644 index 00000000000..59b86ba8b1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go @@ -0,0 +1,32 @@ +package replicationmigrationitems + +import ( + "encoding/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 UpdateMigrationItemInputProperties struct { + ProviderSpecificDetails UpdateMigrationItemProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &UpdateMigrationItemInputProperties{} + +func (s *UpdateMigrationItemInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateMigrationItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalUpdateMigrationItemProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateMigrationItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go new file mode 100644 index 00000000000..9cf525c155d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +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 UpdateMigrationItemProviderSpecificInput interface { +} + +// RawUpdateMigrationItemProviderSpecificInputImpl 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 RawUpdateMigrationItemProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalUpdateMigrationItemProviderSpecificInputImplementation(input []byte) (UpdateMigrationItemProviderSpecificInput, 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 UpdateMigrationItemProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtUpdateMigrationItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtUpdateMigrationItemInput: %+v", err) + } + return out, nil + } + + out := RawUpdateMigrationItemProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtdiskinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtdiskinput.go new file mode 100644 index 00000000000..fc16a80a298 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtdiskinput.go @@ -0,0 +1,13 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtDiskInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId string `json:"diskId"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + IsOSDisk string `json:"isOSDisk"` + LogStorageAccountId string `json:"logStorageAccountId"` + LogStorageAccountSasSecretName string `json:"logStorageAccountSasSecretName"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go new file mode 100644 index 00000000000..55ef94dffb5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go @@ -0,0 +1,65 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableMigrationProviderSpecificInput = VMwareCbtEnableMigrationInput{} + +type VMwareCbtEnableMigrationInput struct { + ConfidentialVMKeyVaultId *string `json:"confidentialVmKeyVaultId,omitempty"` + DataMoverRunAsAccountId string `json:"dataMoverRunAsAccountId"` + DisksToInclude []VMwareCbtDiskInput `json:"disksToInclude"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + PerformSqlBulkRegistration *string `json:"performSqlBulkRegistration,omitempty"` + SeedDiskTags *map[string]string `json:"seedDiskTags,omitempty"` + SnapshotRunAsAccountId string `json:"snapshotRunAsAccountId"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetNetworkId string `json:"targetNetworkId"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId string `json:"targetResourceGroupId"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *VMwareCbtSecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` + VMwareMachineId string `json:"vmwareMachineId"` + + // Fields inherited from EnableMigrationProviderSpecificInput +} + +var _ json.Marshaler = VMwareCbtEnableMigrationInput{} + +func (s VMwareCbtEnableMigrationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtEnableMigrationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtEnableMigrationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtEnableMigrationInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtEnableMigrationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go new file mode 100644 index 00000000000..270108c42c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go @@ -0,0 +1,42 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MigrateProviderSpecificInput = VMwareCbtMigrateInput{} + +type VMwareCbtMigrateInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PerformShutdown string `json:"performShutdown"` + + // Fields inherited from MigrateProviderSpecificInput +} + +var _ json.Marshaler = VMwareCbtMigrateInput{} + +func (s VMwareCbtMigrateInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtMigrateInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtMigrateInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtMigrateInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtMigrateInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go new file mode 100644 index 00000000000..0a737b96c2a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go @@ -0,0 +1,88 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MigrationProviderSpecificSettings = VMwareCbtMigrationDetails{} + +type VMwareCbtMigrationDetails struct { + ApplianceMonitoringDetails *ApplianceMonitoringDetails `json:"applianceMonitoringDetails,omitempty"` + ConfidentialVMKeyVaultId *string `json:"confidentialVmKeyVaultId,omitempty"` + DataMoverRunAsAccountId *string `json:"dataMoverRunAsAccountId,omitempty"` + DeltaSyncProgressPercentage *int64 `json:"deltaSyncProgressPercentage,omitempty"` + DeltaSyncRetryCount *int64 `json:"deltaSyncRetryCount,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + GatewayOperationDetails *GatewayOperationDetails `json:"gatewayOperationDetails,omitempty"` + InitialSeedingProgressPercentage *int64 `json:"initialSeedingProgressPercentage,omitempty"` + InitialSeedingRetryCount *int64 `json:"initialSeedingRetryCount,omitempty"` + IsCheckSumResyncCycle *string `json:"isCheckSumResyncCycle,omitempty"` + LastRecoveryPointId *string `json:"lastRecoveryPointId,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + MigrationProgressPercentage *int64 `json:"migrationProgressPercentage,omitempty"` + MigrationRecoveryPointId *string `json:"migrationRecoveryPointId,omitempty"` + OperationName *string `json:"operationName,omitempty"` + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + ProtectedDisks *[]VMwareCbtProtectedDiskDetails `json:"protectedDisks,omitempty"` + ResumeProgressPercentage *int64 `json:"resumeProgressPercentage,omitempty"` + ResumeRetryCount *int64 `json:"resumeRetryCount,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncRetryCount *int64 `json:"resyncRetryCount,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + SeedDiskTags *map[string]string `json:"seedDiskTags,omitempty"` + SnapshotRunAsAccountId *string `json:"snapshotRunAsAccountId,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SupportedOSVersions *[]string `json:"supportedOSVersions,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetGeneration *string `json:"targetGeneration,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *VMwareCbtSecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + VMNics *[]VMwareCbtNicDetails `json:"vmNics,omitempty"` + VMwareMachineId *string `json:"vmwareMachineId,omitempty"` + + // Fields inherited from MigrationProviderSpecificSettings +} + +var _ json.Marshaler = VMwareCbtMigrationDetails{} + +func (s VMwareCbtMigrationDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtMigrationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtMigrationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtMigrationDetails: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtMigrationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtnicdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtnicdetails.go new file mode 100644 index 00000000000..068195a186f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtnicdetails.go @@ -0,0 +1,21 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtNicDetails struct { + IsPrimaryNic *string `json:"isPrimaryNic,omitempty"` + IsSelectedForMigration *string `json:"isSelectedForMigration,omitempty"` + NicId *string `json:"nicId,omitempty"` + SourceIPAddress *string `json:"sourceIPAddress,omitempty"` + SourceIPAddressType *EthernetAddressType `json:"sourceIPAddressType,omitempty"` + SourceNetworkId *string `json:"sourceNetworkId,omitempty"` + TargetIPAddress *string `json:"targetIPAddress,omitempty"` + TargetIPAddressType *EthernetAddressType `json:"targetIPAddressType,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestIPAddress *string `json:"testIPAddress,omitempty"` + TestIPAddressType *EthernetAddressType `json:"testIPAddressType,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtnicinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtnicinput.go new file mode 100644 index 00000000000..43ec27bd70b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtnicinput.go @@ -0,0 +1,15 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtNicInput struct { + IsPrimaryNic string `json:"isPrimaryNic"` + IsSelectedForMigration *string `json:"isSelectedForMigration,omitempty"` + NicId string `json:"nicId"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetStaticIPAddress *string `json:"targetStaticIPAddress,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestStaticIPAddress *string `json:"testStaticIPAddress,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go new file mode 100644 index 00000000000..7c0fd79c430 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go @@ -0,0 +1,22 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskPath *string `json:"diskPath,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + GatewayOperationDetails *GatewayOperationDetails `json:"gatewayOperationDetails,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + LogStorageAccountSasSecretName *string `json:"logStorageAccountSasSecretName,omitempty"` + SeedBlobUri *string `json:"seedBlobUri,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetBlobUri *string `json:"targetBlobUri,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + TargetManagedDiskId *string `json:"targetManagedDiskId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go new file mode 100644 index 00000000000..bd5bb9ebae3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go @@ -0,0 +1,41 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ResumeReplicationProviderSpecificInput = VMwareCbtResumeReplicationInput{} + +type VMwareCbtResumeReplicationInput struct { + DeleteMigrationResources *string `json:"deleteMigrationResources,omitempty"` + + // Fields inherited from ResumeReplicationProviderSpecificInput +} + +var _ json.Marshaler = VMwareCbtResumeReplicationInput{} + +func (s VMwareCbtResumeReplicationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtResumeReplicationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtResumeReplicationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtResumeReplicationInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtResumeReplicationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtresyncinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtresyncinput.go new file mode 100644 index 00000000000..98d37a993f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtresyncinput.go @@ -0,0 +1,41 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ResyncProviderSpecificInput = VMwareCbtResyncInput{} + +type VMwareCbtResyncInput struct { + SkipCbtReset string `json:"skipCbtReset"` + + // Fields inherited from ResyncProviderSpecificInput +} + +var _ json.Marshaler = VMwareCbtResyncInput{} + +func (s VMwareCbtResyncInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtResyncInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtResyncInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtResyncInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtResyncInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go new file mode 100644 index 00000000000..8bca1ef02df --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go @@ -0,0 +1,12 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtSecurityProfileProperties struct { + IsTargetVMConfidentialEncryptionEnabled *string `json:"isTargetVmConfidentialEncryptionEnabled,omitempty"` + IsTargetVMIntegrityMonitoringEnabled *string `json:"isTargetVmIntegrityMonitoringEnabled,omitempty"` + IsTargetVMSecureBootEnabled *string `json:"isTargetVmSecureBootEnabled,omitempty"` + IsTargetVMTpmEnabled *string `json:"isTargetVmTpmEnabled,omitempty"` + TargetVMSecurityType *SecurityType `json:"targetVmSecurityType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go new file mode 100644 index 00000000000..78879848fb6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go @@ -0,0 +1,44 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestMigrateProviderSpecificInput = VMwareCbtTestMigrateInput{} + +type VMwareCbtTestMigrateInput struct { + NetworkId string `json:"networkId"` + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId string `json:"recoveryPointId"` + VMNics *[]VMwareCbtNicInput `json:"vmNics,omitempty"` + + // Fields inherited from TestMigrateProviderSpecificInput +} + +var _ json.Marshaler = VMwareCbtTestMigrateInput{} + +func (s VMwareCbtTestMigrateInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtTestMigrateInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtTestMigrateInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtTestMigrateInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtTestMigrateInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go new file mode 100644 index 00000000000..54acf609e2b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtUpdateDiskInput struct { + DiskId string `json:"diskId"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go new file mode 100644 index 00000000000..3617cd1a1f2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go @@ -0,0 +1,57 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateMigrationItemProviderSpecificInput = VMwareCbtUpdateMigrationItemInput{} + +type VMwareCbtUpdateMigrationItemInput struct { + LicenseType *LicenseType `json:"licenseType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + VMDisks *[]VMwareCbtUpdateDiskInput `json:"vmDisks,omitempty"` + VMNics *[]VMwareCbtNicInput `json:"vmNics,omitempty"` + + // Fields inherited from UpdateMigrationItemProviderSpecificInput +} + +var _ json.Marshaler = VMwareCbtUpdateMigrationItemInput{} + +func (s VMwareCbtUpdateMigrationItemInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtUpdateMigrationItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/predicates.go new file mode 100644 index 00000000000..38625eaca48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/predicates.go @@ -0,0 +1,32 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MigrationItemOperationPredicate) Matches(input MigrationItem) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/version.go new file mode 100644 index 00000000000..1a229dddf92 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationmigrationitems/version.go @@ -0,0 +1,12 @@ +package replicationmigrationitems + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationmigrationitems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/README.md new file mode 100644 index 00000000000..48a2bd9e22b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings` Documentation + +The `replicationnetworkmappings` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings" +``` + + +### Client Initialization + +```go +client := replicationnetworkmappings.NewReplicationNetworkMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue", "replicationNetworkMappingValue") + +payload := replicationnetworkmappings.CreateNetworkMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue", "replicationNetworkMappingValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue", "replicationNetworkMappingValue") + +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: `ReplicationNetworkMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.ListByReplicationNetworks` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue") + +// alternatively `client.ListByReplicationNetworks(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationNetworksComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Update` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue", "replicationNetworkMappingValue") + +payload := replicationnetworkmappings.UpdateNetworkMappingInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/client.go new file mode 100644 index 00000000000..13d44a2d8e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/client.go @@ -0,0 +1,26 @@ +package replicationnetworkmappings + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationNetworkMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationNetworkMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationNetworkMappingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationnetworkmappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationNetworkMappingsClient: %+v", err) + } + + return &ReplicationNetworkMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetwork.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetwork.go new file mode 100644 index 00000000000..9e297640c4d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetwork.go @@ -0,0 +1,143 @@ +package replicationnetworkmappings + +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 = &ReplicationNetworkId{} + +// ReplicationNetworkId is a struct representing the Resource ID for a Replication Network +type ReplicationNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string +} + +// NewReplicationNetworkID returns a new ReplicationNetworkId struct +func NewReplicationNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string) ReplicationNetworkId { + return ReplicationNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + } +} + +// ParseReplicationNetworkID parses 'input' into a ReplicationNetworkId +func ParseReplicationNetworkID(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkIDInsensitively(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + return nil +} + +// ValidateReplicationNetworkID checks that 'input' can be parsed as a Replication Network ID +func ValidateReplicationNetworkID(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 := ParseReplicationNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network ID +func (id ReplicationNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network ID +func (id ReplicationNetworkId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkValue"), + } +} + +// String returns a human-readable description of this Replication Network ID +func (id ReplicationNetworkId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + } + return fmt.Sprintf("Replication Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetwork_test.go new file mode 100644 index 00000000000..faac47df022 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetwork_test.go @@ -0,0 +1,372 @@ +package replicationnetworkmappings + +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 = &ReplicationNetworkId{} + +func TestNewReplicationNetworkID(t *testing.T) { + id := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationNetworkName != "replicationNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkValue") + } +} + +func TestFormatReplicationNetworkID(t *testing.T) { + actual := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationNetworkName: "replicationNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestParseReplicationNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationNetworkName: "replicationNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKvAlUe", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestSegmentsForReplicationNetworkId(t *testing.T) { + segments := ReplicationNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkId 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/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetworkmapping.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetworkmapping.go new file mode 100644 index 00000000000..f44b667f099 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetworkmapping.go @@ -0,0 +1,152 @@ +package replicationnetworkmappings + +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 = &ReplicationNetworkMappingId{} + +// ReplicationNetworkMappingId is a struct representing the Resource ID for a Replication Network Mapping +type ReplicationNetworkMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string + ReplicationNetworkMappingName string +} + +// NewReplicationNetworkMappingID returns a new ReplicationNetworkMappingId struct +func NewReplicationNetworkMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string, replicationNetworkMappingName string) ReplicationNetworkMappingId { + return ReplicationNetworkMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + ReplicationNetworkMappingName: replicationNetworkMappingName, + } +} + +// ParseReplicationNetworkMappingID parses 'input' into a ReplicationNetworkMappingId +func ParseReplicationNetworkMappingID(input string) (*ReplicationNetworkMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkMappingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkMappingIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkMappingIDInsensitively(input string) (*ReplicationNetworkMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkMappingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkMappingId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + if id.ReplicationNetworkMappingName, ok = input.Parsed["replicationNetworkMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkMappingName", input) + } + + return nil +} + +// ValidateReplicationNetworkMappingID checks that 'input' can be parsed as a Replication Network Mapping ID +func ValidateReplicationNetworkMappingID(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 := ParseReplicationNetworkMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network Mapping ID +func (id ReplicationNetworkMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s/replicationNetworkMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName, id.ReplicationNetworkMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network Mapping ID +func (id ReplicationNetworkMappingId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkValue"), + resourceids.StaticSegment("staticReplicationNetworkMappings", "replicationNetworkMappings", "replicationNetworkMappings"), + resourceids.UserSpecifiedSegment("replicationNetworkMappingName", "replicationNetworkMappingValue"), + } +} + +// String returns a human-readable description of this Replication Network Mapping ID +func (id ReplicationNetworkMappingId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + fmt.Sprintf("Replication Network Mapping Name: %q", id.ReplicationNetworkMappingName), + } + return fmt.Sprintf("Replication Network Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go new file mode 100644 index 00000000000..bd1c5ec1834 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go @@ -0,0 +1,417 @@ +package replicationnetworkmappings + +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 = &ReplicationNetworkMappingId{} + +func TestNewReplicationNetworkMappingID(t *testing.T) { + id := NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue", "replicationNetworkMappingValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationNetworkName != "replicationNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkValue") + } + + if id.ReplicationNetworkMappingName != "replicationNetworkMappingValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkMappingName'", id.ReplicationNetworkMappingName, "replicationNetworkMappingValue") + } +} + +func TestFormatReplicationNetworkMappingID(t *testing.T) { + actual := NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue", "replicationNetworkMappingValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/replicationNetworkMappings/replicationNetworkMappingValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkMappingId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/replicationNetworkMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/replicationNetworkMappings/replicationNetworkMappingValue", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationNetworkName: "replicationNetworkValue", + ReplicationNetworkMappingName: "replicationNetworkMappingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/replicationNetworkMappings/replicationNetworkMappingValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkMappingID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + if actual.ReplicationNetworkMappingName != v.Expected.ReplicationNetworkMappingName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkMappingName", v.Expected.ReplicationNetworkMappingName, actual.ReplicationNetworkMappingName) + } + + } +} + +func TestParseReplicationNetworkMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkMappingId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/replicationNetworkMappings", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKvAlUe/rEpLiCaTiOnNeTwOrKmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/replicationNetworkMappings/replicationNetworkMappingValue", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationNetworkName: "replicationNetworkValue", + ReplicationNetworkMappingName: "replicationNetworkMappingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/replicationNetworkMappings/replicationNetworkMappingValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKvAlUe/rEpLiCaTiOnNeTwOrKmApPiNgS/rEpLiCaTiOnNeTwOrKmApPiNgVaLuE", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKvAlUe", + ReplicationNetworkMappingName: "rEpLiCaTiOnNeTwOrKmApPiNgVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKvAlUe/rEpLiCaTiOnNeTwOrKmApPiNgS/rEpLiCaTiOnNeTwOrKmApPiNgVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkMappingIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + if actual.ReplicationNetworkMappingName != v.Expected.ReplicationNetworkMappingName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkMappingName", v.Expected.ReplicationNetworkMappingName, actual.ReplicationNetworkMappingName) + } + + } +} + +func TestSegmentsForReplicationNetworkMappingId(t *testing.T) { + segments := ReplicationNetworkMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkMappingId 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/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_vault.go new file mode 100644 index 00000000000..8cb746498af --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_vault.go @@ -0,0 +1,125 @@ +package replicationnetworkmappings + +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/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_vault_test.go new file mode 100644 index 00000000000..f8a20abbf51 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationnetworkmappings + +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/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_create.go new file mode 100644 index 00000000000..a4d2be62b74 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_create.go @@ -0,0 +1,75 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkMapping +} + +// Create ... +func (c ReplicationNetworkMappingsClient) Create(ctx context.Context, id ReplicationNetworkMappingId, input CreateNetworkMappingInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationNetworkMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationNetworkMappingId, input CreateNetworkMappingInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_delete.go new file mode 100644 index 00000000000..3adf449be4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_delete.go @@ -0,0 +1,70 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationNetworkMappingsClient) Delete(ctx context.Context, id ReplicationNetworkMappingId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationNetworkMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationNetworkMappingId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_get.go new file mode 100644 index 00000000000..d1f11a0035e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_get.go @@ -0,0 +1,51 @@ +package replicationnetworkmappings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkMapping +} + +// Get ... +func (c ReplicationNetworkMappingsClient) Get(ctx context.Context, id ReplicationNetworkMappingId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_list.go new file mode 100644 index 00000000000..77ba752acb1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_list.go @@ -0,0 +1,91 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkMapping +} + +// List ... +func (c ReplicationNetworkMappingsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationNetworkMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationNetworkMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworkMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate NetworkMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkMapping, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_listbyreplicationnetworks.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_listbyreplicationnetworks.go new file mode 100644 index 00000000000..a2269ba60cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_listbyreplicationnetworks.go @@ -0,0 +1,91 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationNetworksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkMapping +} + +type ListByReplicationNetworksCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkMapping +} + +// ListByReplicationNetworks ... +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworks(ctx context.Context, id ReplicationNetworkId) (result ListByReplicationNetworksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationNetworkMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationNetworksComplete retrieves all the results into a single object +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworksComplete(ctx context.Context, id ReplicationNetworkId) (ListByReplicationNetworksCompleteResult, error) { + return c.ListByReplicationNetworksCompleteMatchingPredicate(ctx, id, NetworkMappingOperationPredicate{}) +} + +// ListByReplicationNetworksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworksCompleteMatchingPredicate(ctx context.Context, id ReplicationNetworkId, predicate NetworkMappingOperationPredicate) (result ListByReplicationNetworksCompleteResult, err error) { + items := make([]NetworkMapping, 0) + + resp, err := c.ListByReplicationNetworks(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationNetworksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_update.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_update.go new file mode 100644 index 00000000000..bbd5fc8d76f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/method_update.go @@ -0,0 +1,75 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkMapping +} + +// Update ... +func (c ReplicationNetworkMappingsClient) Update(ctx context.Context, id ReplicationNetworkMappingId, input UpdateNetworkMappingInput) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ReplicationNetworkMappingsClient) UpdateThenPoll(ctx context.Context, id ReplicationNetworkMappingId, input UpdateNetworkMappingInput) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go new file mode 100644 index 00000000000..338a69b7c24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go @@ -0,0 +1,41 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreateNetworkMappingInput = AzureToAzureCreateNetworkMappingInput{} + +type AzureToAzureCreateNetworkMappingInput struct { + PrimaryNetworkId string `json:"primaryNetworkId"` + + // Fields inherited from FabricSpecificCreateNetworkMappingInput +} + +var _ json.Marshaler = AzureToAzureCreateNetworkMappingInput{} + +func (s AzureToAzureCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go new file mode 100644 index 00000000000..82ee7d7cd78 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go @@ -0,0 +1,42 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NetworkMappingFabricSpecificSettings = AzureToAzureNetworkMappingSettings{} + +type AzureToAzureNetworkMappingSettings struct { + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + + // Fields inherited from NetworkMappingFabricSpecificSettings +} + +var _ json.Marshaler = AzureToAzureNetworkMappingSettings{} + +func (s AzureToAzureNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go new file mode 100644 index 00000000000..3df2303a098 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go @@ -0,0 +1,41 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificUpdateNetworkMappingInput = AzureToAzureUpdateNetworkMappingInput{} + +type AzureToAzureUpdateNetworkMappingInput struct { + PrimaryNetworkId *string `json:"primaryNetworkId,omitempty"` + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput +} + +var _ json.Marshaler = AzureToAzureUpdateNetworkMappingInput{} + +func (s AzureToAzureUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_createnetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_createnetworkmappinginput.go new file mode 100644 index 00000000000..1465b2453c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_createnetworkmappinginput.go @@ -0,0 +1,8 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateNetworkMappingInput struct { + Properties CreateNetworkMappingInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go new file mode 100644 index 00000000000..43ae6995a54 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go @@ -0,0 +1,42 @@ +package replicationnetworkmappings + +import ( + "encoding/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 CreateNetworkMappingInputProperties struct { + FabricSpecificDetails FabricSpecificCreateNetworkMappingInput `json:"fabricSpecificDetails"` + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId string `json:"recoveryNetworkId"` +} + +var _ json.Unmarshaler = &CreateNetworkMappingInputProperties{} + +func (s *CreateNetworkMappingInputProperties) UnmarshalJSON(bytes []byte) error { + type alias CreateNetworkMappingInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into CreateNetworkMappingInputProperties: %+v", err) + } + + s.RecoveryFabricName = decoded.RecoveryFabricName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateNetworkMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificDetails"]; ok { + impl, err := unmarshalFabricSpecificCreateNetworkMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificDetails' for 'CreateNetworkMappingInputProperties': %+v", err) + } + s.FabricSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go new file mode 100644 index 00000000000..24f1403cfe7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go @@ -0,0 +1,69 @@ +package replicationnetworkmappings + +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 FabricSpecificCreateNetworkMappingInput interface { +} + +// RawFabricSpecificCreateNetworkMappingInputImpl 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 RawFabricSpecificCreateNetworkMappingInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalFabricSpecificCreateNetworkMappingInputImplementation(input []byte) (FabricSpecificCreateNetworkMappingInput, 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 FabricSpecificCreateNetworkMappingInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + out := RawFabricSpecificCreateNetworkMappingInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go new file mode 100644 index 00000000000..9b00243a9b2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go @@ -0,0 +1,69 @@ +package replicationnetworkmappings + +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 FabricSpecificUpdateNetworkMappingInput interface { +} + +// RawFabricSpecificUpdateNetworkMappingInputImpl 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 RawFabricSpecificUpdateNetworkMappingInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalFabricSpecificUpdateNetworkMappingInputImplementation(input []byte) (FabricSpecificUpdateNetworkMappingInput, 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 FabricSpecificUpdateNetworkMappingInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + out := RawFabricSpecificUpdateNetworkMappingInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmapping.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmapping.go new file mode 100644 index 00000000000..920122dece0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmapping.go @@ -0,0 +1,12 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go new file mode 100644 index 00000000000..21b3513bb8a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go @@ -0,0 +1,69 @@ +package replicationnetworkmappings + +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 NetworkMappingFabricSpecificSettings interface { +} + +// RawNetworkMappingFabricSpecificSettingsImpl 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 RawNetworkMappingFabricSpecificSettingsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalNetworkMappingFabricSpecificSettingsImplementation(input []byte) (NetworkMappingFabricSpecificSettings, 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 NetworkMappingFabricSpecificSettings into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureNetworkMappingSettings: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureNetworkMappingSettings: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmNetworkMappingSettings: %+v", err) + } + return out, nil + } + + out := RawNetworkMappingFabricSpecificSettingsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmappingproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmappingproperties.go new file mode 100644 index 00000000000..5f4d29ba66e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_networkmappingproperties.go @@ -0,0 +1,54 @@ +package replicationnetworkmappings + +import ( + "encoding/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 NetworkMappingProperties struct { + FabricSpecificSettings NetworkMappingFabricSpecificSettings `json:"fabricSpecificSettings"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryNetworkFriendlyName *string `json:"primaryNetworkFriendlyName,omitempty"` + PrimaryNetworkId *string `json:"primaryNetworkId,omitempty"` + RecoveryFabricArmId *string `json:"recoveryFabricArmId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryNetworkFriendlyName *string `json:"recoveryNetworkFriendlyName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` + State *string `json:"state,omitempty"` +} + +var _ json.Unmarshaler = &NetworkMappingProperties{} + +func (s *NetworkMappingProperties) UnmarshalJSON(bytes []byte) error { + type alias NetworkMappingProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into NetworkMappingProperties: %+v", err) + } + + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryNetworkFriendlyName = decoded.PrimaryNetworkFriendlyName + s.PrimaryNetworkId = decoded.PrimaryNetworkId + s.RecoveryFabricArmId = decoded.RecoveryFabricArmId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryNetworkFriendlyName = decoded.RecoveryNetworkFriendlyName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + s.State = decoded.State + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling NetworkMappingProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificSettings"]; ok { + impl, err := unmarshalNetworkMappingFabricSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificSettings' for 'NetworkMappingProperties': %+v", err) + } + s.FabricSpecificSettings = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_updatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_updatenetworkmappinginput.go new file mode 100644 index 00000000000..12c39d59aee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_updatenetworkmappinginput.go @@ -0,0 +1,8 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateNetworkMappingInput struct { + Properties *UpdateNetworkMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go new file mode 100644 index 00000000000..9f64360d09b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go @@ -0,0 +1,42 @@ +package replicationnetworkmappings + +import ( + "encoding/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 UpdateNetworkMappingInputProperties struct { + FabricSpecificDetails FabricSpecificUpdateNetworkMappingInput `json:"fabricSpecificDetails"` + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` +} + +var _ json.Unmarshaler = &UpdateNetworkMappingInputProperties{} + +func (s *UpdateNetworkMappingInputProperties) UnmarshalJSON(bytes []byte) error { + type alias UpdateNetworkMappingInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into UpdateNetworkMappingInputProperties: %+v", err) + } + + s.RecoveryFabricName = decoded.RecoveryFabricName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateNetworkMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificDetails"]; ok { + impl, err := unmarshalFabricSpecificUpdateNetworkMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificDetails' for 'UpdateNetworkMappingInputProperties': %+v", err) + } + s.FabricSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go new file mode 100644 index 00000000000..e8a8a1a928a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go @@ -0,0 +1,40 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreateNetworkMappingInput = VMmToAzureCreateNetworkMappingInput{} + +type VMmToAzureCreateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificCreateNetworkMappingInput +} + +var _ json.Marshaler = VMmToAzureCreateNetworkMappingInput{} + +func (s VMmToAzureCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go new file mode 100644 index 00000000000..aa741d5d144 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go @@ -0,0 +1,40 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NetworkMappingFabricSpecificSettings = VMmToAzureNetworkMappingSettings{} + +type VMmToAzureNetworkMappingSettings struct { + + // Fields inherited from NetworkMappingFabricSpecificSettings +} + +var _ json.Marshaler = VMmToAzureNetworkMappingSettings{} + +func (s VMmToAzureNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go new file mode 100644 index 00000000000..b496ae4ae1f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go @@ -0,0 +1,40 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificUpdateNetworkMappingInput = VMmToAzureUpdateNetworkMappingInput{} + +type VMmToAzureUpdateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput +} + +var _ json.Marshaler = VMmToAzureUpdateNetworkMappingInput{} + +func (s VMmToAzureUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go new file mode 100644 index 00000000000..62ecb90d0ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go @@ -0,0 +1,40 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreateNetworkMappingInput = VMmToVMmCreateNetworkMappingInput{} + +type VMmToVMmCreateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificCreateNetworkMappingInput +} + +var _ json.Marshaler = VMmToVMmCreateNetworkMappingInput{} + +func (s VMmToVMmCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go new file mode 100644 index 00000000000..b82ddcde87f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go @@ -0,0 +1,40 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NetworkMappingFabricSpecificSettings = VMmToVMmNetworkMappingSettings{} + +type VMmToVMmNetworkMappingSettings struct { + + // Fields inherited from NetworkMappingFabricSpecificSettings +} + +var _ json.Marshaler = VMmToVMmNetworkMappingSettings{} + +func (s VMmToVMmNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go new file mode 100644 index 00000000000..c26929ad37a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go @@ -0,0 +1,40 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificUpdateNetworkMappingInput = VMmToVMmUpdateNetworkMappingInput{} + +type VMmToVMmUpdateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput +} + +var _ json.Marshaler = VMmToVMmUpdateNetworkMappingInput{} + +func (s VMmToVMmUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/predicates.go new file mode 100644 index 00000000000..716755e52f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/predicates.go @@ -0,0 +1,32 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkMappingOperationPredicate) Matches(input NetworkMapping) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/version.go new file mode 100644 index 00000000000..62a0cf6d8a5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworkmappings/version.go @@ -0,0 +1,12 @@ +package replicationnetworkmappings + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationnetworkmappings/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/README.md new file mode 100644 index 00000000000..e647b3aaa52 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks` Documentation + +The `replicationnetworks` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationnetworks" +``` + + +### Client Initialization + +```go +client := replicationnetworks.NewReplicationNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationNetworksClient.Get` + +```go +ctx := context.TODO() +id := replicationnetworks.NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue") + +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: `ReplicationNetworksClient.List` + +```go +ctx := context.TODO() +id := replicationnetworks.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationNetworksClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationnetworks.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/client.go new file mode 100644 index 00000000000..f0116084b00 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/client.go @@ -0,0 +1,26 @@ +package replicationnetworks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationNetworksClient struct { + Client *resourcemanager.Client +} + +func NewReplicationNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationNetworksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationnetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationNetworksClient: %+v", err) + } + + return &ReplicationNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationfabric.go new file mode 100644 index 00000000000..5c326405e18 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationfabric.go @@ -0,0 +1,134 @@ +package replicationnetworks + +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 = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationfabric_test.go new file mode 100644 index 00000000000..d73a6bf21ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationnetworks + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationnetwork.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationnetwork.go new file mode 100644 index 00000000000..a5754dac09c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationnetwork.go @@ -0,0 +1,143 @@ +package replicationnetworks + +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 = &ReplicationNetworkId{} + +// ReplicationNetworkId is a struct representing the Resource ID for a Replication Network +type ReplicationNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string +} + +// NewReplicationNetworkID returns a new ReplicationNetworkId struct +func NewReplicationNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string) ReplicationNetworkId { + return ReplicationNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + } +} + +// ParseReplicationNetworkID parses 'input' into a ReplicationNetworkId +func ParseReplicationNetworkID(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkIDInsensitively(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + return nil +} + +// ValidateReplicationNetworkID checks that 'input' can be parsed as a Replication Network ID +func ValidateReplicationNetworkID(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 := ParseReplicationNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network ID +func (id ReplicationNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network ID +func (id ReplicationNetworkId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkValue"), + } +} + +// String returns a human-readable description of this Replication Network ID +func (id ReplicationNetworkId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + } + return fmt.Sprintf("Replication Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationnetwork_test.go new file mode 100644 index 00000000000..78d87acda6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_replicationnetwork_test.go @@ -0,0 +1,372 @@ +package replicationnetworks + +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 = &ReplicationNetworkId{} + +func TestNewReplicationNetworkID(t *testing.T) { + id := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationNetworkName != "replicationNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkValue") + } +} + +func TestFormatReplicationNetworkID(t *testing.T) { + actual := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationNetworkName: "replicationNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestParseReplicationNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationNetworkName: "replicationNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationNetworks/replicationNetworkValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKvAlUe", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestSegmentsForReplicationNetworkId(t *testing.T) { + segments := ReplicationNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkId 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/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_vault.go new file mode 100644 index 00000000000..47a6a250b9a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_vault.go @@ -0,0 +1,125 @@ +package replicationnetworks + +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/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_vault_test.go new file mode 100644 index 00000000000..4d73b854e04 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationnetworks + +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/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_get.go new file mode 100644 index 00000000000..80cd43618f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_get.go @@ -0,0 +1,51 @@ +package replicationnetworks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Network +} + +// Get ... +func (c ReplicationNetworksClient) Get(ctx context.Context, id ReplicationNetworkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_list.go new file mode 100644 index 00000000000..c9598fa9462 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_list.go @@ -0,0 +1,91 @@ +package replicationnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Network +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Network +} + +// List ... +func (c ReplicationNetworksClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationNetworksClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworksClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate NetworkOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Network, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..3c59d58893f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/method_listbyreplicationfabrics.go @@ -0,0 +1,91 @@ +package replicationnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Network +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Network +} + +// ListByReplicationFabrics ... +func (c ReplicationNetworksClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationNetworksClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, NetworkOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworksClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate NetworkOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]Network, 0) + + resp, err := c.ListByReplicationFabrics(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_network.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_network.go new file mode 100644 index 00000000000..a55b39eacf2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_network.go @@ -0,0 +1,12 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Network struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_networkproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_networkproperties.go new file mode 100644 index 00000000000..7a2c7204a97 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_networkproperties.go @@ -0,0 +1,11 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProperties struct { + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_subnet.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_subnet.go new file mode 100644 index 00000000000..fed1f4919d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/model_subnet.go @@ -0,0 +1,10 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + AddressList *[]string `json:"addressList,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/predicates.go new file mode 100644 index 00000000000..98e4bcc158c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/predicates.go @@ -0,0 +1,32 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkOperationPredicate) Matches(input Network) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationnetworks/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/version.go new file mode 100644 index 00000000000..f9a5f238a56 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationnetworks/version.go @@ -0,0 +1,12 @@ +package replicationnetworks + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationnetworks/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/README.md new file mode 100644 index 00000000000..8aa310eb5dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies` Documentation + +The `replicationpolicies` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationpolicies" +``` + + +### Client Initialization + +```go +client := replicationpolicies.NewReplicationPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationPoliciesClient.Create` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationPolicyValue") + +payload := replicationpolicies.CreatePolicyInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationPolicyValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationPoliciesClient.Get` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationPolicyValue") + +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: `ReplicationPoliciesClient.List` + +```go +ctx := context.TODO() +id := replicationpolicies.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationPoliciesClient.Update` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationPolicyValue") + +payload := replicationpolicies.UpdatePolicyInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/client.go new file mode 100644 index 00000000000..0933df54f51 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/client.go @@ -0,0 +1,26 @@ +package replicationpolicies + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewReplicationPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationPoliciesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationPoliciesClient: %+v", err) + } + + return &ReplicationPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/constants.go new file mode 100644 index 00000000000..b57ea3f114f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/constants.go @@ -0,0 +1,51 @@ +package replicationpolicies + +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 SetMultiVMSyncStatus string + +const ( + SetMultiVMSyncStatusDisable SetMultiVMSyncStatus = "Disable" + SetMultiVMSyncStatusEnable SetMultiVMSyncStatus = "Enable" +) + +func PossibleValuesForSetMultiVMSyncStatus() []string { + return []string{ + string(SetMultiVMSyncStatusDisable), + string(SetMultiVMSyncStatusEnable), + } +} + +func (s *SetMultiVMSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSetMultiVMSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSetMultiVMSyncStatus(input string) (*SetMultiVMSyncStatus, error) { + vals := map[string]SetMultiVMSyncStatus{ + "disable": SetMultiVMSyncStatusDisable, + "enable": SetMultiVMSyncStatusEnable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SetMultiVMSyncStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_replicationpolicy.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_replicationpolicy.go new file mode 100644 index 00000000000..6285aac150a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_replicationpolicy.go @@ -0,0 +1,134 @@ +package replicationpolicies + +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 = &ReplicationPolicyId{} + +// ReplicationPolicyId is a struct representing the Resource ID for a Replication Policy +type ReplicationPolicyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationPolicyName string +} + +// NewReplicationPolicyID returns a new ReplicationPolicyId struct +func NewReplicationPolicyID(subscriptionId string, resourceGroupName string, vaultName string, replicationPolicyName string) ReplicationPolicyId { + return ReplicationPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationPolicyName: replicationPolicyName, + } +} + +// ParseReplicationPolicyID parses 'input' into a ReplicationPolicyId +func ParseReplicationPolicyID(input string) (*ReplicationPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationPolicyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationPolicyIDInsensitively parses 'input' case-insensitively into a ReplicationPolicyId +// note: this method should only be used for API response data and not user input +func ParseReplicationPolicyIDInsensitively(input string) (*ReplicationPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationPolicyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationPolicyId) 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.ReplicationPolicyName, ok = input.Parsed["replicationPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationPolicyName", input) + } + + return nil +} + +// ValidateReplicationPolicyID checks that 'input' can be parsed as a Replication Policy ID +func ValidateReplicationPolicyID(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 := ParseReplicationPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Policy ID +func (id ReplicationPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Policy ID +func (id ReplicationPolicyId) 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("staticReplicationPolicies", "replicationPolicies", "replicationPolicies"), + resourceids.UserSpecifiedSegment("replicationPolicyName", "replicationPolicyValue"), + } +} + +// String returns a human-readable description of this Replication Policy ID +func (id ReplicationPolicyId) 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("Replication Policy Name: %q", id.ReplicationPolicyName), + } + return fmt.Sprintf("Replication Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_replicationpolicy_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_replicationpolicy_test.go new file mode 100644 index 00000000000..54f247287ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_replicationpolicy_test.go @@ -0,0 +1,327 @@ +package replicationpolicies + +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 = &ReplicationPolicyId{} + +func TestNewReplicationPolicyID(t *testing.T) { + id := NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationPolicyValue") + + 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.ReplicationPolicyName != "replicationPolicyValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationPolicyName'", id.ReplicationPolicyName, "replicationPolicyValue") + } +} + +func TestFormatReplicationPolicyID(t *testing.T) { + actual := NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationPolicyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationPolicies/replicationPolicyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationPolicyId + }{ + { + // 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/replicationPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationPolicies/replicationPolicyValue", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationPolicyName: "replicationPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationPolicies/replicationPolicyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationPolicyID(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.ReplicationPolicyName != v.Expected.ReplicationPolicyName { + t.Fatalf("Expected %q but got %q for ReplicationPolicyName", v.Expected.ReplicationPolicyName, actual.ReplicationPolicyName) + } + + } +} + +func TestParseReplicationPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationPolicyId + }{ + { + // 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/replicationPolicies", + Error: 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/rEpLiCaTiOnPoLiCiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationPolicies/replicationPolicyValue", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationPolicyName: "replicationPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationPolicies/replicationPolicyValue/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/rEpLiCaTiOnPoLiCiEs/rEpLiCaTiOnPoLiCyVaLuE", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationPolicyName: "rEpLiCaTiOnPoLiCyVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnPoLiCiEs/rEpLiCaTiOnPoLiCyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationPolicyIDInsensitively(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.ReplicationPolicyName != v.Expected.ReplicationPolicyName { + t.Fatalf("Expected %q but got %q for ReplicationPolicyName", v.Expected.ReplicationPolicyName, actual.ReplicationPolicyName) + } + + } +} + +func TestSegmentsForReplicationPolicyId(t *testing.T) { + segments := ReplicationPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationPolicyId 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/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_vault.go new file mode 100644 index 00000000000..48d1a22fcdd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_vault.go @@ -0,0 +1,125 @@ +package replicationpolicies + +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/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_vault_test.go new file mode 100644 index 00000000000..29a812d25eb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationpolicies + +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/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_create.go new file mode 100644 index 00000000000..2fa363134e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_create.go @@ -0,0 +1,75 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Policy +} + +// Create ... +func (c ReplicationPoliciesClient) Create(ctx context.Context, id ReplicationPolicyId, input CreatePolicyInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationPoliciesClient) CreateThenPoll(ctx context.Context, id ReplicationPolicyId, input CreatePolicyInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_delete.go new file mode 100644 index 00000000000..4e3017160f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_delete.go @@ -0,0 +1,70 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationPoliciesClient) Delete(ctx context.Context, id ReplicationPolicyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationPoliciesClient) DeleteThenPoll(ctx context.Context, id ReplicationPolicyId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_get.go new file mode 100644 index 00000000000..aa3e4a16b6d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_get.go @@ -0,0 +1,51 @@ +package replicationpolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Policy +} + +// Get ... +func (c ReplicationPoliciesClient) Get(ctx context.Context, id ReplicationPolicyId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_list.go new file mode 100644 index 00000000000..f744628a04e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_list.go @@ -0,0 +1,91 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Policy +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Policy +} + +// List ... +func (c ReplicationPoliciesClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Policy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationPoliciesClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PolicyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate PolicyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Policy, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_update.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_update.go new file mode 100644 index 00000000000..91f76915b75 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/method_update.go @@ -0,0 +1,75 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Policy +} + +// Update ... +func (c ReplicationPoliciesClient) Update(ctx context.Context, id ReplicationPolicyId, input UpdatePolicyInput) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ReplicationPoliciesClient) UpdateThenPoll(ctx context.Context, id ReplicationPolicyId, input UpdatePolicyInput) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go new file mode 100644 index 00000000000..b45a259a55f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go @@ -0,0 +1,40 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = A2ACrossClusterMigrationPolicyCreationInput{} + +type A2ACrossClusterMigrationPolicyCreationInput struct { + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = A2ACrossClusterMigrationPolicyCreationInput{} + +func (s A2ACrossClusterMigrationPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2apolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2apolicycreationinput.go new file mode 100644 index 00000000000..cbaba9db768 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2apolicycreationinput.go @@ -0,0 +1,44 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = A2APolicyCreationInput{} + +type A2APolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = A2APolicyCreationInput{} + +func (s A2APolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2APolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2APolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2APolicyCreationInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2APolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2apolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2apolicydetails.go new file mode 100644 index 00000000000..3aa1c5f9fb7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_a2apolicydetails.go @@ -0,0 +1,45 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = A2APolicyDetails{} + +type A2APolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = A2APolicyDetails{} + +func (s A2APolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper A2APolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2APolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2APolicyDetails: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2APolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_createpolicyinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_createpolicyinput.go new file mode 100644 index 00000000000..a1cb3c60fe8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_createpolicyinput.go @@ -0,0 +1,8 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreatePolicyInput struct { + Properties *CreatePolicyInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_createpolicyinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_createpolicyinputproperties.go new file mode 100644 index 00000000000..6e5638e6871 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_createpolicyinputproperties.go @@ -0,0 +1,32 @@ +package replicationpolicies + +import ( + "encoding/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 CreatePolicyInputProperties struct { + ProviderSpecificInput PolicyProviderSpecificInput `json:"providerSpecificInput"` +} + +var _ json.Unmarshaler = &CreatePolicyInputProperties{} + +func (s *CreatePolicyInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreatePolicyInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := unmarshalPolicyProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'CreatePolicyInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go new file mode 100644 index 00000000000..775075b8d2a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go @@ -0,0 +1,46 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = HyperVReplicaAzurePolicyDetails{} + +type HyperVReplicaAzurePolicyDetails struct { + ActiveStorageAccountId *string `json:"activeStorageAccountId,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Encryption *string `json:"encryption,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPointHistoryDurationInHours *int64 `json:"recoveryPointHistoryDurationInHours,omitempty"` + ReplicationInterval *int64 `json:"replicationInterval,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = HyperVReplicaAzurePolicyDetails{} + +func (s HyperVReplicaAzurePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go new file mode 100644 index 00000000000..46599f8373b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go @@ -0,0 +1,45 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = HyperVReplicaAzurePolicyInput{} + +type HyperVReplicaAzurePolicyInput struct { + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPointHistoryDuration *int64 `json:"recoveryPointHistoryDuration,omitempty"` + ReplicationInterval *int64 `json:"replicationInterval,omitempty"` + StorageAccounts *[]string `json:"storageAccounts,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = HyperVReplicaAzurePolicyInput{} + +func (s HyperVReplicaAzurePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabasepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabasepolicydetails.go new file mode 100644 index 00000000000..12bfc95a141 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabasepolicydetails.go @@ -0,0 +1,50 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = HyperVReplicaBasePolicyDetails{} + +type HyperVReplicaBasePolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = HyperVReplicaBasePolicyDetails{} + +func (s HyperVReplicaBasePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBasePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaBasePolicyDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabluepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabluepolicydetails.go new file mode 100644 index 00000000000..ea551ee41d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabluepolicydetails.go @@ -0,0 +1,51 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = HyperVReplicaBluePolicyDetails{} + +type HyperVReplicaBluePolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationFrequencyInSeconds *int64 `json:"replicationFrequencyInSeconds,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = HyperVReplicaBluePolicyDetails{} + +func (s HyperVReplicaBluePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBluePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabluepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabluepolicyinput.go new file mode 100644 index 00000000000..be141866872 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicabluepolicyinput.go @@ -0,0 +1,51 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = HyperVReplicaBluePolicyInput{} + +type HyperVReplicaBluePolicyInput struct { + ReplicationFrequencyInSeconds *int64 `json:"replicationFrequencyInSeconds,omitempty"` + + // Fields inherited from HyperVReplicaPolicyInput + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletion *string `json:"replicaDeletion,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` +} + +var _ json.Marshaler = HyperVReplicaBluePolicyInput{} + +func (s HyperVReplicaBluePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBluePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBluePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBluePolicyInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBluePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicapolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicapolicydetails.go new file mode 100644 index 00000000000..af3773107b1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicapolicydetails.go @@ -0,0 +1,50 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = HyperVReplicaPolicyDetails{} + +type HyperVReplicaPolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = HyperVReplicaPolicyDetails{} + +func (s HyperVReplicaPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaPolicyDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicapolicyinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicapolicyinput.go new file mode 100644 index 00000000000..b8882e26d4e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_hypervreplicapolicyinput.go @@ -0,0 +1,50 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = HyperVReplicaPolicyInput{} + +type HyperVReplicaPolicyInput struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletion *string `json:"replicaDeletion,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = HyperVReplicaPolicyInput{} + +func (s HyperVReplicaPolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaPolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaPolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaPolicyInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaPolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmageazurev2policydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmageazurev2policydetails.go new file mode 100644 index 00000000000..561d2d868c5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmageazurev2policydetails.go @@ -0,0 +1,45 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMageAzureV2PolicyDetails{} + +type InMageAzureV2PolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = InMageAzureV2PolicyDetails{} + +func (s InMageAzureV2PolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2PolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2PolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2PolicyDetails: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2PolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmageazurev2policyinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmageazurev2policyinput.go new file mode 100644 index 00000000000..7e42a20f0e1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmageazurev2policyinput.go @@ -0,0 +1,45 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = InMageAzureV2PolicyInput{} + +type InMageAzureV2PolicyInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = InMageAzureV2PolicyInput{} + +func (s InMageAzureV2PolicyInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2PolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2PolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2PolicyInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2PolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagebasepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagebasepolicydetails.go new file mode 100644 index 00000000000..a9aa31dee55 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagebasepolicydetails.go @@ -0,0 +1,44 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMageBasePolicyDetails{} + +type InMageBasePolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = InMageBasePolicyDetails{} + +func (s InMageBasePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageBasePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageBasePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageBasePolicyDetails: %+v", err) + } + decoded["instanceType"] = "InMageBasePolicyDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageBasePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagepolicydetails.go new file mode 100644 index 00000000000..e5eb997e2da --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagepolicydetails.go @@ -0,0 +1,44 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMagePolicyDetails{} + +type InMagePolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = InMagePolicyDetails{} + +func (s InMagePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMagePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMagePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMagePolicyDetails: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMagePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagepolicyinput.go new file mode 100644 index 00000000000..6d9e7b1e90a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagepolicyinput.go @@ -0,0 +1,44 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = InMagePolicyInput{} + +type InMagePolicyInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = InMagePolicyInput{} + +func (s InMagePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper InMagePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMagePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMagePolicyInput: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMagePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go new file mode 100644 index 00000000000..2939b3a5096 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go @@ -0,0 +1,42 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = InMageRcmFailbackPolicyCreationInput{} + +type InMageRcmFailbackPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmFailbackPolicyCreationInput{} + +func (s InMageRcmFailbackPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go new file mode 100644 index 00000000000..610cd07baff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go @@ -0,0 +1,42 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMageRcmFailbackPolicyDetails{} + +type InMageRcmFailbackPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = InMageRcmFailbackPolicyDetails{} + +func (s InMageRcmFailbackPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmpolicycreationinput.go new file mode 100644 index 00000000000..1960d5ce36e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmpolicycreationinput.go @@ -0,0 +1,44 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = InMageRcmPolicyCreationInput{} + +type InMageRcmPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + EnableMultiVMSync *string `json:"enableMultiVmSync,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmPolicyCreationInput{} + +func (s InMageRcmPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmPolicyCreationInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmpolicydetails.go new file mode 100644 index 00000000000..6d682e3127c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_inmagercmpolicydetails.go @@ -0,0 +1,44 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMageRcmPolicyDetails{} + +type InMageRcmPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + EnableMultiVMSync *string `json:"enableMultiVmSync,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = InMageRcmPolicyDetails{} + +func (s InMageRcmPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmPolicyDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policy.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policy.go new file mode 100644 index 00000000000..f57b4a8530b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policy.go @@ -0,0 +1,12 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Policy struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproperties.go new file mode 100644 index 00000000000..3f6d1fd8bfa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproperties.go @@ -0,0 +1,40 @@ +package replicationpolicies + +import ( + "encoding/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 PolicyProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ProviderSpecificDetails PolicyProviderSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &PolicyProperties{} + +func (s *PolicyProperties) UnmarshalJSON(bytes []byte) error { + type alias PolicyProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into PolicyProperties: %+v", err) + } + + s.FriendlyName = decoded.FriendlyName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PolicyProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalPolicyProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'PolicyProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproviderspecificdetails.go new file mode 100644 index 00000000000..ce5f183fe9e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproviderspecificdetails.go @@ -0,0 +1,133 @@ +package replicationpolicies + +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 PolicyProviderSpecificDetails interface { +} + +// RawPolicyProviderSpecificDetailsImpl 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 RawPolicyProviderSpecificDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalPolicyProviderSpecificDetailsImplementation(input []byte) (PolicyProviderSpecificDetails, 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 PolicyProviderSpecificDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2APolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2APolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBasePolicyDetails") { + var out HyperVReplicaBasePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBasePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplicaBluePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBluePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2PolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2PolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageBasePolicyDetails") { + var out InMageBasePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageBasePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMagePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMagePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtPolicyDetails: %+v", err) + } + return out, nil + } + + out := RawPolicyProviderSpecificDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproviderspecificinput.go new file mode 100644 index 00000000000..51288b6fcb2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_policyproviderspecificinput.go @@ -0,0 +1,117 @@ +package replicationpolicies + +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 PolicyProviderSpecificInput interface { +} + +// RawPolicyProviderSpecificInputImpl 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 RawPolicyProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalPolicyProviderSpecificInputImplementation(input []byte) (PolicyProviderSpecificInput, 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 PolicyProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2APolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2APolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaPolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaPolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2PolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2PolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMagePolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMagePolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtPolicyCreationInput: %+v", err) + } + return out, nil + } + + out := RawPolicyProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_updatepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_updatepolicyinput.go new file mode 100644 index 00000000000..ca0f0a2c86e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_updatepolicyinput.go @@ -0,0 +1,8 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdatePolicyInput struct { + Properties *UpdatePolicyInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_updatepolicyinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_updatepolicyinputproperties.go new file mode 100644 index 00000000000..59351084d98 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_updatepolicyinputproperties.go @@ -0,0 +1,32 @@ +package replicationpolicies + +import ( + "encoding/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 UpdatePolicyInputProperties struct { + ReplicationProviderSettings PolicyProviderSpecificInput `json:"replicationProviderSettings"` +} + +var _ json.Unmarshaler = &UpdatePolicyInputProperties{} + +func (s *UpdatePolicyInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdatePolicyInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["replicationProviderSettings"]; ok { + impl, err := unmarshalPolicyProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReplicationProviderSettings' for 'UpdatePolicyInputProperties': %+v", err) + } + s.ReplicationProviderSettings = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go new file mode 100644 index 00000000000..a2701bda163 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go @@ -0,0 +1,43 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = VMwareCbtPolicyCreationInput{} + +type VMwareCbtPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput +} + +var _ json.Marshaler = VMwareCbtPolicyCreationInput{} + +func (s VMwareCbtPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtPolicyCreationInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_vmwarecbtpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_vmwarecbtpolicydetails.go new file mode 100644 index 00000000000..0541a8187bb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/model_vmwarecbtpolicydetails.go @@ -0,0 +1,43 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = VMwareCbtPolicyDetails{} + +type VMwareCbtPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails +} + +var _ json.Marshaler = VMwareCbtPolicyDetails{} + +func (s VMwareCbtPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtPolicyDetails: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/predicates.go new file mode 100644 index 00000000000..3cb066948b0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/predicates.go @@ -0,0 +1,32 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p PolicyOperationPredicate) Matches(input Policy) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationpolicies/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/version.go new file mode 100644 index 00000000000..ef750735ab4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationpolicies/version.go @@ -0,0 +1,12 @@ +package replicationpolicies + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationpolicies/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/README.md new file mode 100644 index 00000000000..47194de1007 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems` Documentation + +The `replicationprotectableitems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems" +``` + + +### Client Initialization + +```go +client := replicationprotectableitems.NewReplicationProtectableItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectableItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectableitems.NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectableItemValue") + +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: `ReplicationProtectableItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotectableitems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id, replicationprotectableitems.DefaultListByReplicationProtectionContainersOperationOptions())` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id, replicationprotectableitems.DefaultListByReplicationProtectionContainersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/client.go new file mode 100644 index 00000000000..20a533cfe43 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/client.go @@ -0,0 +1,26 @@ +package replicationprotectableitems + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectableItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectableItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectableItemsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationprotectableitems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectableItemsClient: %+v", err) + } + + return &ReplicationProtectableItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/constants.go new file mode 100644 index 00000000000..ba651c88667 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/constants.go @@ -0,0 +1,95 @@ +package replicationprotectableitems + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type PresenceStatus string + +const ( + PresenceStatusNotPresent PresenceStatus = "NotPresent" + PresenceStatusPresent PresenceStatus = "Present" + PresenceStatusUnknown PresenceStatus = "Unknown" +) + +func PossibleValuesForPresenceStatus() []string { + return []string{ + string(PresenceStatusNotPresent), + string(PresenceStatusPresent), + string(PresenceStatusUnknown), + } +} + +func (s *PresenceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePresenceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePresenceStatus(input string) (*PresenceStatus, error) { + vals := map[string]PresenceStatus{ + "notpresent": PresenceStatusNotPresent, + "present": PresenceStatusPresent, + "unknown": PresenceStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PresenceStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectableitem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectableitem.go new file mode 100644 index 00000000000..3ff14cc36ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectableitem.go @@ -0,0 +1,152 @@ +package replicationprotectableitems + +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 = &ReplicationProtectableItemId{} + +// ReplicationProtectableItemId is a struct representing the Resource ID for a Replication Protectable Item +type ReplicationProtectableItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectableItemName string +} + +// NewReplicationProtectableItemID returns a new ReplicationProtectableItemId struct +func NewReplicationProtectableItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectableItemName string) ReplicationProtectableItemId { + return ReplicationProtectableItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectableItemName: replicationProtectableItemName, + } +} + +// ParseReplicationProtectableItemID parses 'input' into a ReplicationProtectableItemId +func ParseReplicationProtectableItemID(input string) (*ReplicationProtectableItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectableItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectableItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectableItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectableItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectableItemIDInsensitively(input string) (*ReplicationProtectableItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectableItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectableItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectableItemId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectableItemName, ok = input.Parsed["replicationProtectableItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectableItemName", input) + } + + return nil +} + +// ValidateReplicationProtectableItemID checks that 'input' can be parsed as a Replication Protectable Item ID +func ValidateReplicationProtectableItemID(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 := ParseReplicationProtectableItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protectable Item ID +func (id ReplicationProtectableItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectableItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectableItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protectable Item ID +func (id ReplicationProtectableItemId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationProtectableItems", "replicationProtectableItems", "replicationProtectableItems"), + resourceids.UserSpecifiedSegment("replicationProtectableItemName", "replicationProtectableItemValue"), + } +} + +// String returns a human-readable description of this Replication Protectable Item ID +func (id ReplicationProtectableItemId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protectable Item Name: %q", id.ReplicationProtectableItemName), + } + return fmt.Sprintf("Replication Protectable Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectableitem_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectableitem_test.go new file mode 100644 index 00000000000..7b6ed0c9f56 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectableitem_test.go @@ -0,0 +1,417 @@ +package replicationprotectableitems + +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 = &ReplicationProtectableItemId{} + +func TestNewReplicationProtectableItemID(t *testing.T) { + id := NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectableItemValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationProtectableItemName != "replicationProtectableItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectableItemName'", id.ReplicationProtectableItemName, "replicationProtectableItemValue") + } +} + +func TestFormatReplicationProtectableItemID(t *testing.T) { + actual := NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectableItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectableItems/replicationProtectableItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectableItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectableItemId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectableItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectableItems/replicationProtectableItemValue", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectableItemName: "replicationProtectableItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectableItems/replicationProtectableItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectableItemID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectableItemName != v.Expected.ReplicationProtectableItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectableItemName", v.Expected.ReplicationProtectableItemName, actual.ReplicationProtectableItemName) + } + + } +} + +func TestParseReplicationProtectableItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectableItemId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectableItems", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTaBlEiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectableItems/replicationProtectableItemValue", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectableItemName: "replicationProtectableItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectableItems/replicationProtectableItemValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTaBlEiTeMs/rEpLiCaTiOnPrOtEcTaBlEiTeMvAlUe", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationProtectableItemName: "rEpLiCaTiOnPrOtEcTaBlEiTeMvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTaBlEiTeMs/rEpLiCaTiOnPrOtEcTaBlEiTeMvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectableItemIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectableItemName != v.Expected.ReplicationProtectableItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectableItemName", v.Expected.ReplicationProtectableItemName, actual.ReplicationProtectableItemName) + } + + } +} + +func TestSegmentsForReplicationProtectableItemId(t *testing.T) { + segments := ReplicationProtectableItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectableItemId 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/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..f2ebb607310 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectioncontainer.go @@ -0,0 +1,143 @@ +package replicationprotectableitems + +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 = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..4011650193d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectableitems + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/method_get.go new file mode 100644 index 00000000000..c54f2d84c12 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/method_get.go @@ -0,0 +1,51 @@ +package replicationprotectableitems + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProtectableItem +} + +// Get ... +func (c ReplicationProtectableItemsClient) Get(ctx context.Context, id ReplicationProtectableItemId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..5dcb3a26532 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,123 @@ +package replicationprotectableitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectableItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectableItem +} + +type ListByReplicationProtectionContainersOperationOptions struct { + Filter *string + Take *string +} + +func DefaultListByReplicationProtectionContainersOperationOptions() ListByReplicationProtectionContainersOperationOptions { + return ListByReplicationProtectionContainersOperationOptions{} +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Take != nil { + out.Append("$take", fmt.Sprintf("%v", *o.Take)) + } + return &out +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationProtectableItems", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectableItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, options, ProtectableItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions, predicate ProtectableItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ProtectableItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_configurationsettings.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_configurationsettings.go new file mode 100644 index 00000000000..cd0e26b0746 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_configurationsettings.go @@ -0,0 +1,69 @@ +package replicationprotectableitems + +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 ConfigurationSettings interface { +} + +// RawConfigurationSettingsImpl 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 RawConfigurationSettingsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalConfigurationSettingsImplementation(input []byte) (ConfigurationSettings, 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 ConfigurationSettings into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "HyperVVirtualMachine") { + var out HyperVVirtualMachineDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVVirtualMachineDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ReplicationGroupDetails") { + var out ReplicationGroupDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ReplicationGroupDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareVirtualMachine") { + var out VMwareVirtualMachineDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareVirtualMachineDetails: %+v", err) + } + return out, nil + } + + out := RawConfigurationSettingsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_diskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_diskdetails.go new file mode 100644 index 00000000000..f418a8a199a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_diskdetails.go @@ -0,0 +1,11 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskDetails struct { + MaxSizeMB *int64 `json:"maxSizeMB,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_diskvolumedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_diskvolumedetails.go new file mode 100644 index 00000000000..a1807b2e5d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_diskvolumedetails.go @@ -0,0 +1,9 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskVolumeDetails struct { + Label *string `json:"label,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_healtherror.go new file mode 100644 index 00000000000..dd836fd7405 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotectableitems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go new file mode 100644 index 00000000000..73a1c26e708 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go @@ -0,0 +1,48 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ConfigurationSettings = HyperVVirtualMachineDetails{} + +type HyperVVirtualMachineDetails struct { + DiskDetails *[]DiskDetails `json:"diskDetails,omitempty"` + Generation *string `json:"generation,omitempty"` + HasFibreChannelAdapter *PresenceStatus `json:"hasFibreChannelAdapter,omitempty"` + HasPhysicalDisk *PresenceStatus `json:"hasPhysicalDisk,omitempty"` + HasSharedVhd *PresenceStatus `json:"hasSharedVhd,omitempty"` + HyperVHostId *string `json:"hyperVHostId,omitempty"` + OsDetails *OSDetails `json:"osDetails,omitempty"` + SourceItemId *string `json:"sourceItemId,omitempty"` + + // Fields inherited from ConfigurationSettings +} + +var _ json.Marshaler = HyperVVirtualMachineDetails{} + +func (s HyperVVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVVirtualMachineDetails: %+v", err) + } + decoded["instanceType"] = "HyperVVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_inmagediskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_inmagediskdetails.go new file mode 100644 index 00000000000..a4233f28136 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_inmagediskdetails.go @@ -0,0 +1,13 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskDetails struct { + DiskConfiguration *string `json:"diskConfiguration,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskSizeInMB *string `json:"diskSizeInMB,omitempty"` + DiskType *string `json:"diskType,omitempty"` + VolumeList *[]DiskVolumeDetails `json:"volumeList,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_innerhealtherror.go new file mode 100644 index 00000000000..ee306e7b230 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotectableitems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_osdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_osdetails.go new file mode 100644 index 00000000000..7b38e793990 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_osdetails.go @@ -0,0 +1,13 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDetails struct { + OSMajorVersion *string `json:"oSMajorVersion,omitempty"` + OSMinorVersion *string `json:"oSMinorVersion,omitempty"` + OSVersion *string `json:"oSVersion,omitempty"` + OsEdition *string `json:"osEdition,omitempty"` + OsType *string `json:"osType,omitempty"` + ProductType *string `json:"productType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_protectableitem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_protectableitem.go new file mode 100644 index 00000000000..f2996c6b514 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_protectableitem.go @@ -0,0 +1,12 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectableItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_protectableitemproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_protectableitemproperties.go new file mode 100644 index 00000000000..5559fc9f13c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_protectableitemproperties.go @@ -0,0 +1,50 @@ +package replicationprotectableitems + +import ( + "encoding/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 ProtectableItemProperties struct { + CustomDetails ConfigurationSettings `json:"customDetails"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionReadinessErrors *[]string `json:"protectionReadinessErrors,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationProtectedItemId *string `json:"replicationProtectedItemId,omitempty"` + SupportedReplicationProviders *[]string `json:"supportedReplicationProviders,omitempty"` +} + +var _ json.Unmarshaler = &ProtectableItemProperties{} + +func (s *ProtectableItemProperties) UnmarshalJSON(bytes []byte) error { + type alias ProtectableItemProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectableItemProperties: %+v", err) + } + + s.FriendlyName = decoded.FriendlyName + s.ProtectionReadinessErrors = decoded.ProtectionReadinessErrors + s.ProtectionStatus = decoded.ProtectionStatus + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationProtectedItemId = decoded.ReplicationProtectedItemId + s.SupportedReplicationProviders = decoded.SupportedReplicationProviders + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectableItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := unmarshalConfigurationSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'ProtectableItemProperties': %+v", err) + } + s.CustomDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_replicationgroupdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_replicationgroupdetails.go new file mode 100644 index 00000000000..2afdac69d0e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_replicationgroupdetails.go @@ -0,0 +1,40 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ConfigurationSettings = ReplicationGroupDetails{} + +type ReplicationGroupDetails struct { + + // Fields inherited from ConfigurationSettings +} + +var _ json.Marshaler = ReplicationGroupDetails{} + +func (s ReplicationGroupDetails) MarshalJSON() ([]byte, error) { + type wrapper ReplicationGroupDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ReplicationGroupDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ReplicationGroupDetails: %+v", err) + } + decoded["instanceType"] = "ReplicationGroupDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ReplicationGroupDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go new file mode 100644 index 00000000000..1ae50cf4cc7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go @@ -0,0 +1,48 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ConfigurationSettings = VMmVirtualMachineDetails{} + +type VMmVirtualMachineDetails struct { + + // Fields inherited from HyperVVirtualMachineDetails + DiskDetails *[]DiskDetails `json:"diskDetails,omitempty"` + Generation *string `json:"generation,omitempty"` + HasFibreChannelAdapter *PresenceStatus `json:"hasFibreChannelAdapter,omitempty"` + HasPhysicalDisk *PresenceStatus `json:"hasPhysicalDisk,omitempty"` + HasSharedVhd *PresenceStatus `json:"hasSharedVhd,omitempty"` + HyperVHostId *string `json:"hyperVHostId,omitempty"` + OsDetails *OSDetails `json:"osDetails,omitempty"` + SourceItemId *string `json:"sourceItemId,omitempty"` +} + +var _ json.Marshaler = VMmVirtualMachineDetails{} + +func (s VMmVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper VMmVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmVirtualMachineDetails: %+v", err) + } + decoded["instanceType"] = "VmmVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go new file mode 100644 index 00000000000..8eb8ecdf063 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go @@ -0,0 +1,50 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ConfigurationSettings = VMwareVirtualMachineDetails{} + +type VMwareVirtualMachineDetails struct { + AgentGeneratedId *string `json:"agentGeneratedId,omitempty"` + AgentInstalled *string `json:"agentInstalled,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskDetails *[]InMageDiskDetails `json:"diskDetails,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + OsType *string `json:"osType,omitempty"` + PoweredOn *string `json:"poweredOn,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + + // Fields inherited from ConfigurationSettings +} + +var _ json.Marshaler = VMwareVirtualMachineDetails{} + +func (s VMwareVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareVirtualMachineDetails: %+v", err) + } + decoded["instanceType"] = "VMwareVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/predicates.go new file mode 100644 index 00000000000..cd7684d6433 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectableItemOperationPredicate) Matches(input ProtectableItem) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/version.go new file mode 100644 index 00000000000..bb3e09136ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectableitems/version.go @@ -0,0 +1,12 @@ +package replicationprotectableitems + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationprotectableitems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/README.md new file mode 100644 index 00000000000..5e08a276cdc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/README.md @@ -0,0 +1,373 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems` Documentation + +The `replicationprotecteditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems" +``` + + +### Client Initialization + +```go +client := replicationprotecteditems.NewReplicationProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectedItemsClient.AddDisks` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.AddDisksInput{ + // ... +} + + +if err := client.AddDisksThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ApplyRecoveryPoint` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.ApplyRecoveryPointInput{ + // ... +} + + +if err := client.ApplyRecoveryPointThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.EnableProtectionInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.DisableProtectionInput{ + // ... +} + + +if err := client.DeleteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.FailoverCancel` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +if err := client.FailoverCancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.FailoverCommit` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +if err := client.FailoverCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +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: `ReplicationProtectedItemsClient.List` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, replicationprotecteditems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationprotecteditems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.PlannedFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.PlannedFailoverInput{ + // ... +} + + +if err := client.PlannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Purge` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.RemoveDisks` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.RemoveDisksInput{ + // ... +} + + +if err := client.RemoveDisksThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.RepairReplication` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +if err := client.RepairReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Reprotect` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.ReverseReplicationInput{ + // ... +} + + +if err := client.ReprotectThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ResolveHealthErrors` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.ResolveHealthInput{ + // ... +} + + +if err := client.ResolveHealthErrorsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.SwitchProvider` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.SwitchProviderInput{ + // ... +} + + +if err := client.SwitchProviderThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.TestFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.TestFailoverInput{ + // ... +} + + +if err := client.TestFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.TestFailoverCleanup` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.TestFailoverCleanupInput{ + // ... +} + + +if err := client.TestFailoverCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UnplannedFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.UnplannedFailoverInput{ + // ... +} + + +if err := client.UnplannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Update` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.UpdateReplicationProtectedItemInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UpdateAppliance` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.UpdateApplianceForReplicationProtectedItemInput{ + // ... +} + + +if err := client.UpdateApplianceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UpdateMobilityService` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +payload := replicationprotecteditems.UpdateMobilityServiceRequest{ + // ... +} + + +if err := client.UpdateMobilityServiceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/client.go new file mode 100644 index 00000000000..83b59be406c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/client.go @@ -0,0 +1,26 @@ +package replicationprotecteditems + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectedItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectedItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectedItemsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationprotecteditems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectedItemsClient: %+v", err) + } + + return &ReplicationProtectedItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/constants.go new file mode 100644 index 00000000000..f367fd9788b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/constants.go @@ -0,0 +1,832 @@ +package replicationprotecteditems + +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 AgentUpgradeBlockedReason string + +const ( + AgentUpgradeBlockedReasonAgentNoHeartbeat AgentUpgradeBlockedReason = "AgentNoHeartbeat" + AgentUpgradeBlockedReasonAlreadyOnLatestVersion AgentUpgradeBlockedReason = "AlreadyOnLatestVersion" + AgentUpgradeBlockedReasonDistroIsNotReported AgentUpgradeBlockedReason = "DistroIsNotReported" + AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade AgentUpgradeBlockedReason = "DistroNotSupportedForUpgrade" + AgentUpgradeBlockedReasonIncompatibleApplianceVersion AgentUpgradeBlockedReason = "IncompatibleApplianceVersion" + AgentUpgradeBlockedReasonInvalidAgentVersion AgentUpgradeBlockedReason = "InvalidAgentVersion" + AgentUpgradeBlockedReasonInvalidDriverVersion AgentUpgradeBlockedReason = "InvalidDriverVersion" + AgentUpgradeBlockedReasonMissingUpgradePath AgentUpgradeBlockedReason = "MissingUpgradePath" + AgentUpgradeBlockedReasonNotProtected AgentUpgradeBlockedReason = "NotProtected" + AgentUpgradeBlockedReasonProcessServerNoHeartbeat AgentUpgradeBlockedReason = "ProcessServerNoHeartbeat" + AgentUpgradeBlockedReasonRcmProxyNoHeartbeat AgentUpgradeBlockedReason = "RcmProxyNoHeartbeat" + AgentUpgradeBlockedReasonRebootRequired AgentUpgradeBlockedReason = "RebootRequired" + AgentUpgradeBlockedReasonUnknown AgentUpgradeBlockedReason = "Unknown" + AgentUpgradeBlockedReasonUnsupportedProtectionScenario AgentUpgradeBlockedReason = "UnsupportedProtectionScenario" +) + +func PossibleValuesForAgentUpgradeBlockedReason() []string { + return []string{ + string(AgentUpgradeBlockedReasonAgentNoHeartbeat), + string(AgentUpgradeBlockedReasonAlreadyOnLatestVersion), + string(AgentUpgradeBlockedReasonDistroIsNotReported), + string(AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade), + string(AgentUpgradeBlockedReasonIncompatibleApplianceVersion), + string(AgentUpgradeBlockedReasonInvalidAgentVersion), + string(AgentUpgradeBlockedReasonInvalidDriverVersion), + string(AgentUpgradeBlockedReasonMissingUpgradePath), + string(AgentUpgradeBlockedReasonNotProtected), + string(AgentUpgradeBlockedReasonProcessServerNoHeartbeat), + string(AgentUpgradeBlockedReasonRcmProxyNoHeartbeat), + string(AgentUpgradeBlockedReasonRebootRequired), + string(AgentUpgradeBlockedReasonUnknown), + string(AgentUpgradeBlockedReasonUnsupportedProtectionScenario), + } +} + +func (s *AgentUpgradeBlockedReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentUpgradeBlockedReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentUpgradeBlockedReason(input string) (*AgentUpgradeBlockedReason, error) { + vals := map[string]AgentUpgradeBlockedReason{ + "agentnoheartbeat": AgentUpgradeBlockedReasonAgentNoHeartbeat, + "alreadyonlatestversion": AgentUpgradeBlockedReasonAlreadyOnLatestVersion, + "distroisnotreported": AgentUpgradeBlockedReasonDistroIsNotReported, + "distronotsupportedforupgrade": AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade, + "incompatibleapplianceversion": AgentUpgradeBlockedReasonIncompatibleApplianceVersion, + "invalidagentversion": AgentUpgradeBlockedReasonInvalidAgentVersion, + "invaliddriverversion": AgentUpgradeBlockedReasonInvalidDriverVersion, + "missingupgradepath": AgentUpgradeBlockedReasonMissingUpgradePath, + "notprotected": AgentUpgradeBlockedReasonNotProtected, + "processservernoheartbeat": AgentUpgradeBlockedReasonProcessServerNoHeartbeat, + "rcmproxynoheartbeat": AgentUpgradeBlockedReasonRcmProxyNoHeartbeat, + "rebootrequired": AgentUpgradeBlockedReasonRebootRequired, + "unknown": AgentUpgradeBlockedReasonUnknown, + "unsupportedprotectionscenario": AgentUpgradeBlockedReasonUnsupportedProtectionScenario, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentUpgradeBlockedReason(input) + return &out, nil +} + +type AutoProtectionOfDataDisk string + +const ( + AutoProtectionOfDataDiskDisabled AutoProtectionOfDataDisk = "Disabled" + AutoProtectionOfDataDiskEnabled AutoProtectionOfDataDisk = "Enabled" +) + +func PossibleValuesForAutoProtectionOfDataDisk() []string { + return []string{ + string(AutoProtectionOfDataDiskDisabled), + string(AutoProtectionOfDataDiskEnabled), + } +} + +func (s *AutoProtectionOfDataDisk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoProtectionOfDataDisk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoProtectionOfDataDisk(input string) (*AutoProtectionOfDataDisk, error) { + vals := map[string]AutoProtectionOfDataDisk{ + "disabled": AutoProtectionOfDataDiskDisabled, + "enabled": AutoProtectionOfDataDiskEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoProtectionOfDataDisk(input) + return &out, nil +} + +type ChurnOptionSelected string + +const ( + ChurnOptionSelectedHigh ChurnOptionSelected = "High" + ChurnOptionSelectedNormal ChurnOptionSelected = "Normal" +) + +func PossibleValuesForChurnOptionSelected() []string { + return []string{ + string(ChurnOptionSelectedHigh), + string(ChurnOptionSelectedNormal), + } +} + +func (s *ChurnOptionSelected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChurnOptionSelected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChurnOptionSelected(input string) (*ChurnOptionSelected, error) { + vals := map[string]ChurnOptionSelected{ + "high": ChurnOptionSelectedHigh, + "normal": ChurnOptionSelectedNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ChurnOptionSelected(input) + return &out, nil +} + +type DisableProtectionReason string + +const ( + DisableProtectionReasonMigrationComplete DisableProtectionReason = "MigrationComplete" + DisableProtectionReasonNotSpecified DisableProtectionReason = "NotSpecified" +) + +func PossibleValuesForDisableProtectionReason() []string { + return []string{ + string(DisableProtectionReasonMigrationComplete), + string(DisableProtectionReasonNotSpecified), + } +} + +func (s *DisableProtectionReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDisableProtectionReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDisableProtectionReason(input string) (*DisableProtectionReason, error) { + vals := map[string]DisableProtectionReason{ + "migrationcomplete": DisableProtectionReasonMigrationComplete, + "notspecified": DisableProtectionReasonNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DisableProtectionReason(input) + return &out, nil +} + +type DiskAccountType string + +const ( + DiskAccountTypePremiumLRS DiskAccountType = "Premium_LRS" + DiskAccountTypeStandardLRS DiskAccountType = "Standard_LRS" + DiskAccountTypeStandardSSDLRS DiskAccountType = "StandardSSD_LRS" +) + +func PossibleValuesForDiskAccountType() []string { + return []string{ + string(DiskAccountTypePremiumLRS), + string(DiskAccountTypeStandardLRS), + string(DiskAccountTypeStandardSSDLRS), + } +} + +func (s *DiskAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskAccountType(input string) (*DiskAccountType, error) { + vals := map[string]DiskAccountType{ + "premium_lrs": DiskAccountTypePremiumLRS, + "standard_lrs": DiskAccountTypeStandardLRS, + "standardssd_lrs": DiskAccountTypeStandardSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskAccountType(input) + return &out, nil +} + +type DiskReplicationProgressHealth string + +const ( + DiskReplicationProgressHealthInProgress DiskReplicationProgressHealth = "InProgress" + DiskReplicationProgressHealthNoProgress DiskReplicationProgressHealth = "NoProgress" + DiskReplicationProgressHealthNone DiskReplicationProgressHealth = "None" + DiskReplicationProgressHealthQueued DiskReplicationProgressHealth = "Queued" + DiskReplicationProgressHealthSlowProgress DiskReplicationProgressHealth = "SlowProgress" +) + +func PossibleValuesForDiskReplicationProgressHealth() []string { + return []string{ + string(DiskReplicationProgressHealthInProgress), + string(DiskReplicationProgressHealthNoProgress), + string(DiskReplicationProgressHealthNone), + string(DiskReplicationProgressHealthQueued), + string(DiskReplicationProgressHealthSlowProgress), + } +} + +func (s *DiskReplicationProgressHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskReplicationProgressHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskReplicationProgressHealth(input string) (*DiskReplicationProgressHealth, error) { + vals := map[string]DiskReplicationProgressHealth{ + "inprogress": DiskReplicationProgressHealthInProgress, + "noprogress": DiskReplicationProgressHealthNoProgress, + "none": DiskReplicationProgressHealthNone, + "queued": DiskReplicationProgressHealthQueued, + "slowprogress": DiskReplicationProgressHealthSlowProgress, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskReplicationProgressHealth(input) + return &out, nil +} + +type EthernetAddressType string + +const ( + EthernetAddressTypeDynamic EthernetAddressType = "Dynamic" + EthernetAddressTypeStatic EthernetAddressType = "Static" +) + +func PossibleValuesForEthernetAddressType() []string { + return []string{ + string(EthernetAddressTypeDynamic), + string(EthernetAddressTypeStatic), + } +} + +func (s *EthernetAddressType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEthernetAddressType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEthernetAddressType(input string) (*EthernetAddressType, error) { + vals := map[string]EthernetAddressType{ + "dynamic": EthernetAddressTypeDynamic, + "static": EthernetAddressTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EthernetAddressType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type InMageRcmFailbackRecoveryPointType string + +const ( + InMageRcmFailbackRecoveryPointTypeApplicationConsistent InMageRcmFailbackRecoveryPointType = "ApplicationConsistent" + InMageRcmFailbackRecoveryPointTypeCrashConsistent InMageRcmFailbackRecoveryPointType = "CrashConsistent" +) + +func PossibleValuesForInMageRcmFailbackRecoveryPointType() []string { + return []string{ + string(InMageRcmFailbackRecoveryPointTypeApplicationConsistent), + string(InMageRcmFailbackRecoveryPointTypeCrashConsistent), + } +} + +func (s *InMageRcmFailbackRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageRcmFailbackRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageRcmFailbackRecoveryPointType(input string) (*InMageRcmFailbackRecoveryPointType, error) { + vals := map[string]InMageRcmFailbackRecoveryPointType{ + "applicationconsistent": InMageRcmFailbackRecoveryPointTypeApplicationConsistent, + "crashconsistent": InMageRcmFailbackRecoveryPointTypeCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageRcmFailbackRecoveryPointType(input) + return &out, nil +} + +type LicenseType string + +const ( + LicenseTypeNoLicenseType LicenseType = "NoLicenseType" + LicenseTypeNotSpecified LicenseType = "NotSpecified" + LicenseTypeWindowsServer LicenseType = "WindowsServer" +) + +func PossibleValuesForLicenseType() []string { + return []string{ + string(LicenseTypeNoLicenseType), + string(LicenseTypeNotSpecified), + string(LicenseTypeWindowsServer), + } +} + +func (s *LicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseType(input string) (*LicenseType, error) { + vals := map[string]LicenseType{ + "nolicensetype": LicenseTypeNoLicenseType, + "notspecified": LicenseTypeNotSpecified, + "windowsserver": LicenseTypeWindowsServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseType(input) + return &out, nil +} + +type MobilityAgentUpgradeState string + +const ( + MobilityAgentUpgradeStateCommit MobilityAgentUpgradeState = "Commit" + MobilityAgentUpgradeStateCompleted MobilityAgentUpgradeState = "Completed" + MobilityAgentUpgradeStateNone MobilityAgentUpgradeState = "None" + MobilityAgentUpgradeStateStarted MobilityAgentUpgradeState = "Started" +) + +func PossibleValuesForMobilityAgentUpgradeState() []string { + return []string{ + string(MobilityAgentUpgradeStateCommit), + string(MobilityAgentUpgradeStateCompleted), + string(MobilityAgentUpgradeStateNone), + string(MobilityAgentUpgradeStateStarted), + } +} + +func (s *MobilityAgentUpgradeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMobilityAgentUpgradeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMobilityAgentUpgradeState(input string) (*MobilityAgentUpgradeState, error) { + vals := map[string]MobilityAgentUpgradeState{ + "commit": MobilityAgentUpgradeStateCommit, + "completed": MobilityAgentUpgradeStateCompleted, + "none": MobilityAgentUpgradeStateNone, + "started": MobilityAgentUpgradeStateStarted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MobilityAgentUpgradeState(input) + return &out, nil +} + +type MultiVMGroupCreateOption string + +const ( + MultiVMGroupCreateOptionAutoCreated MultiVMGroupCreateOption = "AutoCreated" + MultiVMGroupCreateOptionUserSpecified MultiVMGroupCreateOption = "UserSpecified" +) + +func PossibleValuesForMultiVMGroupCreateOption() []string { + return []string{ + string(MultiVMGroupCreateOptionAutoCreated), + string(MultiVMGroupCreateOptionUserSpecified), + } +} + +func (s *MultiVMGroupCreateOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiVMGroupCreateOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiVMGroupCreateOption(input string) (*MultiVMGroupCreateOption, error) { + vals := map[string]MultiVMGroupCreateOption{ + "autocreated": MultiVMGroupCreateOptionAutoCreated, + "userspecified": MultiVMGroupCreateOptionUserSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiVMGroupCreateOption(input) + return &out, nil +} + +type PlannedFailoverStatus string + +const ( + PlannedFailoverStatusCancelled PlannedFailoverStatus = "Cancelled" + PlannedFailoverStatusFailed PlannedFailoverStatus = "Failed" + PlannedFailoverStatusSucceeded PlannedFailoverStatus = "Succeeded" + PlannedFailoverStatusUnknown PlannedFailoverStatus = "Unknown" +) + +func PossibleValuesForPlannedFailoverStatus() []string { + return []string{ + string(PlannedFailoverStatusCancelled), + string(PlannedFailoverStatusFailed), + string(PlannedFailoverStatusSucceeded), + string(PlannedFailoverStatusUnknown), + } +} + +func (s *PlannedFailoverStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePlannedFailoverStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePlannedFailoverStatus(input string) (*PlannedFailoverStatus, error) { + vals := map[string]PlannedFailoverStatus{ + "cancelled": PlannedFailoverStatusCancelled, + "failed": PlannedFailoverStatusFailed, + "succeeded": PlannedFailoverStatusSucceeded, + "unknown": PlannedFailoverStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PlannedFailoverStatus(input) + return &out, nil +} + +type RecoveryPointType string + +const ( + RecoveryPointTypeCustom RecoveryPointType = "Custom" + RecoveryPointTypeLatestTag RecoveryPointType = "LatestTag" + RecoveryPointTypeLatestTime RecoveryPointType = "LatestTime" +) + +func PossibleValuesForRecoveryPointType() []string { + return []string{ + string(RecoveryPointTypeCustom), + string(RecoveryPointTypeLatestTag), + string(RecoveryPointTypeLatestTime), + } +} + +func (s *RecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointType(input string) (*RecoveryPointType, error) { + vals := map[string]RecoveryPointType{ + "custom": RecoveryPointTypeCustom, + "latesttag": RecoveryPointTypeLatestTag, + "latesttime": RecoveryPointTypeLatestTime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointType(input) + return &out, nil +} + +type ResyncState string + +const ( + ResyncStateNone ResyncState = "None" + ResyncStatePreparedForResynchronization ResyncState = "PreparedForResynchronization" + ResyncStateStartedResynchronization ResyncState = "StartedResynchronization" +) + +func PossibleValuesForResyncState() []string { + return []string{ + string(ResyncStateNone), + string(ResyncStatePreparedForResynchronization), + string(ResyncStateStartedResynchronization), + } +} + +func (s *ResyncState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResyncState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResyncState(input string) (*ResyncState, error) { + vals := map[string]ResyncState{ + "none": ResyncStateNone, + "preparedforresynchronization": ResyncStatePreparedForResynchronization, + "startedresynchronization": ResyncStateStartedResynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResyncState(input) + return &out, nil +} + +type SqlServerLicenseType string + +const ( + SqlServerLicenseTypeAHUB SqlServerLicenseType = "AHUB" + SqlServerLicenseTypeNoLicenseType SqlServerLicenseType = "NoLicenseType" + SqlServerLicenseTypeNotSpecified SqlServerLicenseType = "NotSpecified" + SqlServerLicenseTypePAYG SqlServerLicenseType = "PAYG" +) + +func PossibleValuesForSqlServerLicenseType() []string { + return []string{ + string(SqlServerLicenseTypeAHUB), + string(SqlServerLicenseTypeNoLicenseType), + string(SqlServerLicenseTypeNotSpecified), + string(SqlServerLicenseTypePAYG), + } +} + +func (s *SqlServerLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlServerLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlServerLicenseType(input string) (*SqlServerLicenseType, error) { + vals := map[string]SqlServerLicenseType{ + "ahub": SqlServerLicenseTypeAHUB, + "nolicensetype": SqlServerLicenseTypeNoLicenseType, + "notspecified": SqlServerLicenseTypeNotSpecified, + "payg": SqlServerLicenseTypePAYG, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlServerLicenseType(input) + return &out, nil +} + +type VMEncryptionType string + +const ( + VMEncryptionTypeNotEncrypted VMEncryptionType = "NotEncrypted" + VMEncryptionTypeOnePassEncrypted VMEncryptionType = "OnePassEncrypted" + VMEncryptionTypeTwoPassEncrypted VMEncryptionType = "TwoPassEncrypted" +) + +func PossibleValuesForVMEncryptionType() []string { + return []string{ + string(VMEncryptionTypeNotEncrypted), + string(VMEncryptionTypeOnePassEncrypted), + string(VMEncryptionTypeTwoPassEncrypted), + } +} + +func (s *VMEncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMEncryptionType(input string) (*VMEncryptionType, error) { + vals := map[string]VMEncryptionType{ + "notencrypted": VMEncryptionTypeNotEncrypted, + "onepassencrypted": VMEncryptionTypeOnePassEncrypted, + "twopassencrypted": VMEncryptionTypeTwoPassEncrypted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMEncryptionType(input) + return &out, nil +} + +type VMReplicationProgressHealth string + +const ( + VMReplicationProgressHealthInProgress VMReplicationProgressHealth = "InProgress" + VMReplicationProgressHealthNoProgress VMReplicationProgressHealth = "NoProgress" + VMReplicationProgressHealthNone VMReplicationProgressHealth = "None" + VMReplicationProgressHealthSlowProgress VMReplicationProgressHealth = "SlowProgress" +) + +func PossibleValuesForVMReplicationProgressHealth() []string { + return []string{ + string(VMReplicationProgressHealthInProgress), + string(VMReplicationProgressHealthNoProgress), + string(VMReplicationProgressHealthNone), + string(VMReplicationProgressHealthSlowProgress), + } +} + +func (s *VMReplicationProgressHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMReplicationProgressHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMReplicationProgressHealth(input string) (*VMReplicationProgressHealth, error) { + vals := map[string]VMReplicationProgressHealth{ + "inprogress": VMReplicationProgressHealthInProgress, + "noprogress": VMReplicationProgressHealthNoProgress, + "none": VMReplicationProgressHealthNone, + "slowprogress": VMReplicationProgressHealthSlowProgress, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMReplicationProgressHealth(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotecteditem.go new file mode 100644 index 00000000000..a4d9c713c79 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotecteditem.go @@ -0,0 +1,152 @@ +package replicationprotecteditems + +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 = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(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 := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemValue"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..9e4396e020c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotecteditem_test.go @@ -0,0 +1,417 @@ +package replicationprotecteditems + +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 = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemValue") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectedItemName: "replicationProtectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectedItemName: "replicationProtectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId 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/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..63b73b46ba7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotectioncontainer.go @@ -0,0 +1,143 @@ +package replicationprotecteditems + +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 = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..1d83d090968 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotecteditems + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_vault.go new file mode 100644 index 00000000000..e45001d1a91 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_vault.go @@ -0,0 +1,125 @@ +package replicationprotecteditems + +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/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_vault_test.go new file mode 100644 index 00000000000..73d755d340c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotecteditems + +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/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_adddisks.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_adddisks.go new file mode 100644 index 00000000000..36621c48786 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_adddisks.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddDisksOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// AddDisks ... +func (c ReplicationProtectedItemsClient) AddDisks(ctx context.Context, id ReplicationProtectedItemId, input AddDisksInput) (result AddDisksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addDisks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// AddDisksThenPoll performs AddDisks then polls until it's completed +func (c ReplicationProtectedItemsClient) AddDisksThenPoll(ctx context.Context, id ReplicationProtectedItemId, input AddDisksInput) error { + result, err := c.AddDisks(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AddDisks: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AddDisks: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_applyrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_applyrecoverypoint.go new file mode 100644 index 00000000000..01aa0179078 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_applyrecoverypoint.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyRecoveryPointOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// ApplyRecoveryPoint ... +func (c ReplicationProtectedItemsClient) ApplyRecoveryPoint(ctx context.Context, id ReplicationProtectedItemId, input ApplyRecoveryPointInput) (result ApplyRecoveryPointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applyRecoveryPoint", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ApplyRecoveryPointThenPoll performs ApplyRecoveryPoint then polls until it's completed +func (c ReplicationProtectedItemsClient) ApplyRecoveryPointThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ApplyRecoveryPointInput) error { + result, err := c.ApplyRecoveryPoint(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApplyRecoveryPoint: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApplyRecoveryPoint: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_create.go new file mode 100644 index 00000000000..0058b44ea0f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_create.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// Create ... +func (c ReplicationProtectedItemsClient) Create(ctx context.Context, id ReplicationProtectedItemId, input EnableProtectionInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectedItemsClient) CreateThenPoll(ctx context.Context, id ReplicationProtectedItemId, input EnableProtectionInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_delete.go new file mode 100644 index 00000000000..6de58173ab5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_delete.go @@ -0,0 +1,74 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationProtectedItemsClient) Delete(ctx context.Context, id ReplicationProtectedItemId, input DisableProtectionInput) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationProtectedItemsClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectedItemId, input DisableProtectionInput) error { + result, err := c.Delete(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_failovercancel.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_failovercancel.go new file mode 100644 index 00000000000..0232cdf2c30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_failovercancel.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCancelOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// FailoverCancel ... +func (c ReplicationProtectedItemsClient) FailoverCancel(ctx context.Context, id ReplicationProtectedItemId) (result FailoverCancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCancel", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCancelThenPoll performs FailoverCancel then polls until it's completed +func (c ReplicationProtectedItemsClient) FailoverCancelThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.FailoverCancel(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_failovercommit.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_failovercommit.go new file mode 100644 index 00000000000..be595e3aeda --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_failovercommit.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// FailoverCommit ... +func (c ReplicationProtectedItemsClient) FailoverCommit(ctx context.Context, id ReplicationProtectedItemId) (result FailoverCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCommit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCommitThenPoll performs FailoverCommit then polls until it's completed +func (c ReplicationProtectedItemsClient) FailoverCommitThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.FailoverCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_get.go new file mode 100644 index 00000000000..d836f7412fa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_get.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// Get ... +func (c ReplicationProtectedItemsClient) Get(ctx context.Context, id ReplicationProtectedItemId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_list.go new file mode 100644 index 00000000000..879b6efa592 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_list.go @@ -0,0 +1,123 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectedItem +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectedItem +} + +type ListOperationOptions struct { + Filter *string + SkipToken *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + return &out +} + +// List ... +func (c ReplicationProtectedItemsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationProtectedItems", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationProtectedItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectedItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationProtectedItemOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectedItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationProtectedItemOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationProtectedItem, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..6b6028217cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,91 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectedItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectedItem +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationProtectedItems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationProtectedItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, ReplicationProtectedItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, predicate ReplicationProtectedItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ReplicationProtectedItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_plannedfailover.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_plannedfailover.go new file mode 100644 index 00000000000..12c98413547 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_plannedfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// PlannedFailover ... +func (c ReplicationProtectedItemsClient) PlannedFailover(ctx context.Context, id ReplicationProtectedItemId, input PlannedFailoverInput) (result PlannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/plannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PlannedFailoverThenPoll performs PlannedFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) PlannedFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input PlannedFailoverInput) error { + result, err := c.PlannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PlannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PlannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_purge.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_purge.go new file mode 100644 index 00000000000..9917dd3997d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_purge.go @@ -0,0 +1,70 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationProtectedItemsClient) Purge(ctx context.Context, id ReplicationProtectedItemId) (result PurgeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationProtectedItemsClient) PurgeThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_removedisks.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_removedisks.go new file mode 100644 index 00000000000..13caa5a940e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_removedisks.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveDisksOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// RemoveDisks ... +func (c ReplicationProtectedItemsClient) RemoveDisks(ctx context.Context, id ReplicationProtectedItemId, input RemoveDisksInput) (result RemoveDisksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeDisks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RemoveDisksThenPoll performs RemoveDisks then polls until it's completed +func (c ReplicationProtectedItemsClient) RemoveDisksThenPoll(ctx context.Context, id ReplicationProtectedItemId, input RemoveDisksInput) error { + result, err := c.RemoveDisks(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RemoveDisks: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveDisks: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_repairreplication.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_repairreplication.go new file mode 100644 index 00000000000..f755248eff3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_repairreplication.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RepairReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// RepairReplication ... +func (c ReplicationProtectedItemsClient) RepairReplication(ctx context.Context, id ReplicationProtectedItemId) (result RepairReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/repairReplication", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RepairReplicationThenPoll performs RepairReplication then polls until it's completed +func (c ReplicationProtectedItemsClient) RepairReplicationThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.RepairReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing RepairReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RepairReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_reprotect.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_reprotect.go new file mode 100644 index 00000000000..3da5ec114b7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_reprotect.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReprotectOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// Reprotect ... +func (c ReplicationProtectedItemsClient) Reprotect(ctx context.Context, id ReplicationProtectedItemId, input ReverseReplicationInput) (result ReprotectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reProtect", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReprotectThenPoll performs Reprotect then polls until it's completed +func (c ReplicationProtectedItemsClient) ReprotectThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ReverseReplicationInput) error { + result, err := c.Reprotect(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Reprotect: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reprotect: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_resolvehealtherrors.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_resolvehealtherrors.go new file mode 100644 index 00000000000..8d61f1ff79d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_resolvehealtherrors.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthErrorsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// ResolveHealthErrors ... +func (c ReplicationProtectedItemsClient) ResolveHealthErrors(ctx context.Context, id ReplicationProtectedItemId, input ResolveHealthInput) (result ResolveHealthErrorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resolveHealthErrors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResolveHealthErrorsThenPoll performs ResolveHealthErrors then polls until it's completed +func (c ReplicationProtectedItemsClient) ResolveHealthErrorsThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ResolveHealthInput) error { + result, err := c.ResolveHealthErrors(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResolveHealthErrors: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResolveHealthErrors: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_switchprovider.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_switchprovider.go new file mode 100644 index 00000000000..b49df7171d5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_switchprovider.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProviderOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// SwitchProvider ... +func (c ReplicationProtectedItemsClient) SwitchProvider(ctx context.Context, id ReplicationProtectedItemId, input SwitchProviderInput) (result SwitchProviderOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchProvider", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SwitchProviderThenPoll performs SwitchProvider then polls until it's completed +func (c ReplicationProtectedItemsClient) SwitchProviderThenPoll(ctx context.Context, id ReplicationProtectedItemId, input SwitchProviderInput) error { + result, err := c.SwitchProvider(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwitchProvider: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwitchProvider: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_testfailover.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_testfailover.go new file mode 100644 index 00000000000..b9e2751e6ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_testfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// TestFailover ... +func (c ReplicationProtectedItemsClient) TestFailover(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverInput) (result TestFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverThenPoll performs TestFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) TestFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverInput) error { + result, err := c.TestFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_testfailovercleanup.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_testfailovercleanup.go new file mode 100644 index 00000000000..70adce69ef2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_testfailovercleanup.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// TestFailoverCleanup ... +func (c ReplicationProtectedItemsClient) TestFailoverCleanup(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverCleanupInput) (result TestFailoverCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailoverCleanup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverCleanupThenPoll performs TestFailoverCleanup then polls until it's completed +func (c ReplicationProtectedItemsClient) TestFailoverCleanupThenPoll(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverCleanupInput) error { + result, err := c.TestFailoverCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailoverCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailoverCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_unplannedfailover.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_unplannedfailover.go new file mode 100644 index 00000000000..dce055d914d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_unplannedfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UnplannedFailover ... +func (c ReplicationProtectedItemsClient) UnplannedFailover(ctx context.Context, id ReplicationProtectedItemId, input UnplannedFailoverInput) (result UnplannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unplannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UnplannedFailoverThenPoll performs UnplannedFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) UnplannedFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UnplannedFailoverInput) error { + result, err := c.UnplannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnplannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnplannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_update.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_update.go new file mode 100644 index 00000000000..2c21514383f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_update.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// Update ... +func (c ReplicationProtectedItemsClient) Update(ctx context.Context, id ReplicationProtectedItemId, input UpdateReplicationProtectedItemInput) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ReplicationProtectedItemsClient) UpdateThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateReplicationProtectedItemInput) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_updateappliance.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_updateappliance.go new file mode 100644 index 00000000000..e4dbc3fbd83 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_updateappliance.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateApplianceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UpdateAppliance ... +func (c ReplicationProtectedItemsClient) UpdateAppliance(ctx context.Context, id ReplicationProtectedItemId, input UpdateApplianceForReplicationProtectedItemInput) (result UpdateApplianceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateAppliance", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateApplianceThenPoll performs UpdateAppliance then polls until it's completed +func (c ReplicationProtectedItemsClient) UpdateApplianceThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateApplianceForReplicationProtectedItemInput) error { + result, err := c.UpdateAppliance(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateAppliance: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateAppliance: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_updatemobilityservice.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_updatemobilityservice.go new file mode 100644 index 00000000000..36e2bbdfc24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/method_updatemobilityservice.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMobilityServiceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UpdateMobilityService ... +func (c ReplicationProtectedItemsClient) UpdateMobilityService(ctx context.Context, id ReplicationProtectedItemId, input UpdateMobilityServiceRequest) (result UpdateMobilityServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateMobilityService", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateMobilityServiceThenPoll performs UpdateMobilityService then polls until it's completed +func (c ReplicationProtectedItemsClient) UpdateMobilityServiceThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateMobilityServiceRequest) error { + result, err := c.UpdateMobilityService(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateMobilityService: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateMobilityService: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aadddisksinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aadddisksinput.go new file mode 100644 index 00000000000..814464cdc24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aadddisksinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AddDisksProviderSpecificInput = A2AAddDisksInput{} + +type A2AAddDisksInput struct { + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from AddDisksProviderSpecificInput +} + +var _ json.Marshaler = A2AAddDisksInput{} + +func (s A2AAddDisksInput) MarshalJSON() ([]byte, error) { + type wrapper A2AAddDisksInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AAddDisksInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AAddDisksInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AAddDisksInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go new file mode 100644 index 00000000000..c2159e729a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = A2AApplyRecoveryPointInput{} + +type A2AApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput +} + +var _ json.Marshaler = A2AApplyRecoveryPointInput{} + +func (s A2AApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper A2AApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AApplyRecoveryPointInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go new file mode 100644 index 00000000000..16ecd46bef5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = A2ACrossClusterMigrationApplyRecoveryPointInput{} + +type A2ACrossClusterMigrationApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput +} + +var _ json.Marshaler = A2ACrossClusterMigrationApplyRecoveryPointInput{} + +func (s A2ACrossClusterMigrationApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go new file mode 100644 index 00000000000..c03870f7d5d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = A2ACrossClusterMigrationEnableProtectionInput{} + +type A2ACrossClusterMigrationEnableProtectionInput struct { + FabricObjectId *string `json:"fabricObjectId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput +} + +var _ json.Marshaler = A2ACrossClusterMigrationEnableProtectionInput{} + +func (s A2ACrossClusterMigrationEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go new file mode 100644 index 00000000000..7af3fda8ac7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go @@ -0,0 +1,46 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = A2ACrossClusterMigrationReplicationDetails{} + +type A2ACrossClusterMigrationReplicationDetails struct { + FabricObjectId *string `json:"fabricObjectId,omitempty"` + LifecycleId *string `json:"lifecycleId,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = A2ACrossClusterMigrationReplicationDetails{} + +func (s A2ACrossClusterMigrationReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aenableprotectioninput.go new file mode 100644 index 00000000000..980f1d278cb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aenableprotectioninput.go @@ -0,0 +1,61 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = A2AEnableProtectionInput{} + +type A2AEnableProtectionInput struct { + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId string `json:"fabricObjectId"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryAzureNetworkId *string `json:"recoveryAzureNetworkId,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput +} + +var _ json.Marshaler = A2AEnableProtectionInput{} + +func (s A2AEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2AEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AEnableProtectionInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go new file mode 100644 index 00000000000..1f03409b8f6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go @@ -0,0 +1,30 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedDiskDetails struct { + AllowedDiskLevelOperation *[]string `json:"allowedDiskLevelOperation,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DekKeyVaultArmId *string `json:"dekKeyVaultArmId,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *string `json:"diskState,omitempty"` + DiskType *string `json:"diskType,omitempty"` + DiskUri *string `json:"diskUri,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + IsDiskEncrypted *bool `json:"isDiskEncrypted,omitempty"` + IsDiskKeyEncrypted *bool `json:"isDiskKeyEncrypted,omitempty"` + KekKeyVaultArmId *string `json:"kekKeyVaultArmId,omitempty"` + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryDiskAzureStorageAccountId *string `json:"primaryDiskAzureStorageAccountId,omitempty"` + PrimaryStagingAzureStorageAccountId *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + RecoveryAzureStorageAccountId *string `json:"recoveryAzureStorageAccountId,omitempty"` + RecoveryDiskUri *string `json:"recoveryDiskUri,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go new file mode 100644 index 00000000000..f531b7431ce --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go @@ -0,0 +1,35 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedManagedDiskDetails struct { + AllowedDiskLevelOperation *[]string `json:"allowedDiskLevelOperation,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DekKeyVaultArmId *string `json:"dekKeyVaultArmId,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *string `json:"diskState,omitempty"` + DiskType *string `json:"diskType,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + IsDiskEncrypted *bool `json:"isDiskEncrypted,omitempty"` + IsDiskKeyEncrypted *bool `json:"isDiskKeyEncrypted,omitempty"` + KekKeyVaultArmId *string `json:"kekKeyVaultArmId,omitempty"` + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryDiskEncryptionSetId *string `json:"primaryDiskEncryptionSetId,omitempty"` + PrimaryStagingAzureStorageAccountId *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryOrignalTargetDiskId *string `json:"recoveryOrignalTargetDiskId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryReplicaDiskId *string `json:"recoveryReplicaDiskId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + RecoveryTargetDiskId *string `json:"recoveryTargetDiskId,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aremovedisksinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aremovedisksinput.go new file mode 100644 index 00000000000..32f05ed2728 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aremovedisksinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RemoveDisksProviderSpecificInput = A2ARemoveDisksInput{} + +type A2ARemoveDisksInput struct { + VMDisksUris *[]string `json:"vmDisksUris,omitempty"` + VMManagedDisksIds *[]string `json:"vmManagedDisksIds,omitempty"` + + // Fields inherited from RemoveDisksProviderSpecificInput +} + +var _ json.Marshaler = A2ARemoveDisksInput{} + +func (s A2ARemoveDisksInput) MarshalJSON() ([]byte, error) { + type wrapper A2ARemoveDisksInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ARemoveDisksInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ARemoveDisksInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ARemoveDisksInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2areplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2areplicationdetails.go new file mode 100644 index 00000000000..37236e5b27e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2areplicationdetails.go @@ -0,0 +1,96 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = A2AReplicationDetails{} + +type A2AReplicationDetails struct { + AgentCertificateExpiryDate *string `json:"agentCertificateExpiryDate,omitempty"` + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + ChurnOptionSelected *ChurnOptionSelected `json:"churnOptionSelected,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + InitialPrimaryExtendedLocation *edgezones.Model `json:"initialPrimaryExtendedLocation,omitempty"` + InitialPrimaryFabricLocation *string `json:"initialPrimaryFabricLocation,omitempty"` + InitialPrimaryZone *string `json:"initialPrimaryZone,omitempty"` + InitialRecoveryExtendedLocation *edgezones.Model `json:"initialRecoveryExtendedLocation,omitempty"` + InitialRecoveryFabricLocation *string `json:"initialRecoveryFabricLocation,omitempty"` + InitialRecoveryZone *string `json:"initialRecoveryZone,omitempty"` + IsReplicationAgentCertificateUpdateRequired *bool `json:"isReplicationAgentCertificateUpdateRequired,omitempty"` + IsReplicationAgentUpdateRequired *bool `json:"isReplicationAgentUpdateRequired,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LifecycleId *string `json:"lifecycleId,omitempty"` + ManagementId *string `json:"managementId,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + MultiVMGroupCreateOption *MultiVMGroupCreateOption `json:"multiVmGroupCreateOption,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryAvailabilityZone *string `json:"primaryAvailabilityZone,omitempty"` + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + ProtectedDisks *[]A2AProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectedManagedDisks *[]A2AProtectedManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + RecoveryAvailabilitySet *string `json:"recoveryAvailabilitySet,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryAzureGeneration *string `json:"recoveryAzureGeneration,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudService *string `json:"recoveryCloudService,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RecoveryFabricObjectId *string `json:"recoveryFabricObjectId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + TestFailoverRecoveryFabricObjectId *string `json:"testFailoverRecoveryFabricObjectId,omitempty"` + TfoAzureVMName *string `json:"tfoAzureVMName,omitempty"` + UnprotectedDisks *[]A2AUnprotectedDiskDetails `json:"unprotectedDisks,omitempty"` + VMEncryptionType *VMEncryptionType `json:"vmEncryptionType,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + VMSyncedConfigDetails *AzureToAzureVMSyncedConfigDetails `json:"vmSyncedConfigDetails,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = A2AReplicationDetails{} + +func (s A2AReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReplicationDetails: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2areprotectinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2areprotectinput.go new file mode 100644 index 00000000000..2695d902be3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2areprotectinput.go @@ -0,0 +1,46 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = A2AReprotectInput{} + +type A2AReprotectInput struct { + PolicyId *string `json:"policyId,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput +} + +var _ json.Marshaler = A2AReprotectInput{} + +func (s A2AReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper A2AReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReprotectInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2atestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2atestfailoverinput.go new file mode 100644 index 00000000000..000fecac67e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2atestfailoverinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = A2ATestFailoverInput{} + +type A2ATestFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput +} + +var _ json.Marshaler = A2ATestFailoverInput{} + +func (s A2ATestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2ATestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ATestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ATestFailoverInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ATestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go new file mode 100644 index 00000000000..8c21ffe9c8e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = A2AUnplannedFailoverInput{} + +type A2AUnplannedFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput +} + +var _ json.Marshaler = A2AUnplannedFailoverInput{} + +func (s A2AUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUnplannedFailoverInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go new file mode 100644 index 00000000000..e0a224a5724 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AUnprotectedDiskDetails struct { + DiskAutoProtectionStatus *AutoProtectionOfDataDisk `json:"diskAutoProtectionStatus,omitempty"` + DiskLunId *int64 `json:"diskLunId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..f03e4a9a89a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go @@ -0,0 +1,49 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateReplicationProtectedItemProviderInput = A2AUpdateReplicationProtectedItemInput{} + +type A2AUpdateReplicationProtectedItemInput struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + ManagedDiskUpdateDetails *[]A2AVMManagedDiskUpdateDetails `json:"managedDiskUpdateDetails,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + TfoAzureVMName *string `json:"tfoAzureVMName,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput +} + +var _ json.Marshaler = A2AUpdateReplicationProtectedItemInput{} + +func (s A2AUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmdiskinputdetails.go new file mode 100644 index 00000000000..c7aef1ff04a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmdiskinputdetails.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryAzureStorageAccountId string `json:"recoveryAzureStorageAccountId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go new file mode 100644 index 00000000000..d233d499b30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go @@ -0,0 +1,14 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go new file mode 100644 index 00000000000..a021eaff3de --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskUpdateDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId *string `json:"diskId,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksinput.go new file mode 100644 index 00000000000..fb324e0c8f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddDisksInput struct { + Properties *AddDisksInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksinputproperties.go new file mode 100644 index 00000000000..2613527d5d4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksinputproperties.go @@ -0,0 +1,32 @@ +package replicationprotecteditems + +import ( + "encoding/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 AddDisksInputProperties struct { + ProviderSpecificDetails AddDisksProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &AddDisksInputProperties{} + +func (s *AddDisksInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AddDisksInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalAddDisksProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'AddDisksInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksproviderspecificinput.go new file mode 100644 index 00000000000..a47bc604b1d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_adddisksproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 AddDisksProviderSpecificInput interface { +} + +// RawAddDisksProviderSpecificInputImpl 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 RawAddDisksProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAddDisksProviderSpecificInputImplementation(input []byte) (AddDisksProviderSpecificInput, 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 AddDisksProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AAddDisksInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AAddDisksInput: %+v", err) + } + return out, nil + } + + out := RawAddDisksProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointinput.go new file mode 100644 index 00000000000..6ae39e3cd2f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyRecoveryPointInput struct { + Properties ApplyRecoveryPointInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go new file mode 100644 index 00000000000..debfef14272 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/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 ApplyRecoveryPointInputProperties struct { + ProviderSpecificDetails ApplyRecoveryPointProviderSpecificInput `json:"providerSpecificDetails"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` +} + +var _ json.Unmarshaler = &ApplyRecoveryPointInputProperties{} + +func (s *ApplyRecoveryPointInputProperties) UnmarshalJSON(bytes []byte) error { + type alias ApplyRecoveryPointInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ApplyRecoveryPointInputProperties: %+v", err) + } + + s.RecoveryPointId = decoded.RecoveryPointId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ApplyRecoveryPointInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalApplyRecoveryPointProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ApplyRecoveryPointInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go new file mode 100644 index 00000000000..59c1321593c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go @@ -0,0 +1,85 @@ +package replicationprotecteditems + +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 ApplyRecoveryPointProviderSpecificInput interface { +} + +// RawApplyRecoveryPointProviderSpecificInputImpl 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 RawApplyRecoveryPointProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalApplyRecoveryPointProviderSpecificInputImplementation(input []byte) (ApplyRecoveryPointProviderSpecificInput, 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 ApplyRecoveryPointProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + out := RawApplyRecoveryPointProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go new file mode 100644 index 00000000000..7632016e150 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureToAzureVMSyncedConfigDetails struct { + InputEndpoints *[]InputEndpoint `json:"inputEndpoints,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_azurevmdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_azurevmdiskdetails.go new file mode 100644 index 00000000000..d2778fb03f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_azurevmdiskdetails.go @@ -0,0 +1,17 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMDiskDetails struct { + CustomTargetDiskName *string `json:"customTargetDiskName,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + LunId *string `json:"lunId,omitempty"` + MaxSizeMB *string `json:"maxSizeMB,omitempty"` + TargetDiskLocation *string `json:"targetDiskLocation,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_currentscenariodetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_currentscenariodetails.go new file mode 100644 index 00000000000..af5783a8a50 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_currentscenariodetails.go @@ -0,0 +1,28 @@ +package replicationprotecteditems + +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 CurrentScenarioDetails struct { + JobId *string `json:"jobId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentScenarioDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentScenarioDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectioninput.go new file mode 100644 index 00000000000..c09eed86ccb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableProtectionInput struct { + Properties DisableProtectionInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectioninputproperties.go new file mode 100644 index 00000000000..bc2bea03f8b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectioninputproperties.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/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 DisableProtectionInputProperties struct { + DisableProtectionReason *DisableProtectionReason `json:"disableProtectionReason,omitempty"` + ReplicationProviderInput DisableProtectionProviderSpecificInput `json:"replicationProviderInput"` +} + +var _ json.Unmarshaler = &DisableProtectionInputProperties{} + +func (s *DisableProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + type alias DisableProtectionInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into DisableProtectionInputProperties: %+v", err) + } + + s.DisableProtectionReason = decoded.DisableProtectionReason + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DisableProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["replicationProviderInput"]; ok { + impl, err := unmarshalDisableProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReplicationProviderInput' for 'DisableProtectionInputProperties': %+v", err) + } + s.ReplicationProviderInput = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..72ae183f48d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 DisableProtectionProviderSpecificInput interface { +} + +// RawDisableProtectionProviderSpecificInputImpl 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 RawDisableProtectionProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalDisableProtectionProviderSpecificInputImplementation(input []byte) (DisableProtectionProviderSpecificInput, 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 DisableProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageDisableProtectionProviderSpecificInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageDisableProtectionProviderSpecificInput: %+v", err) + } + return out, nil + } + + out := RawDisableProtectionProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskdetails.go new file mode 100644 index 00000000000..f64e47bcb4c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskDetails struct { + MaxSizeMB *int64 `json:"maxSizeMB,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskencryptioninfo.go new file mode 100644 index 00000000000..57df685211a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..6ccd7c74d35 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectioninput.go new file mode 100644 index 00000000000..1fc5ffdfc7b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnableProtectionInput struct { + Properties *EnableProtectionInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectioninputproperties.go new file mode 100644 index 00000000000..dfbab8a6577 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectioninputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/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 EnableProtectionInputProperties struct { + PolicyId *string `json:"policyId,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + ProviderSpecificDetails EnableProtectionProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &EnableProtectionInputProperties{} + +func (s *EnableProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + type alias EnableProtectionInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into EnableProtectionInputProperties: %+v", err) + } + + s.PolicyId = decoded.PolicyId + s.ProtectableItemId = decoded.ProtectableItemId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EnableProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalEnableProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EnableProtectionInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..c23af95ecaa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go @@ -0,0 +1,93 @@ +package replicationprotecteditems + +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 EnableProtectionProviderSpecificInput interface { +} + +// RawEnableProtectionProviderSpecificInputImpl 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 RawEnableProtectionProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalEnableProtectionProviderSpecificInputImplementation(input []byte) (EnableProtectionProviderSpecificInput, 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 EnableProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2EnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2EnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmEnableProtectionInput: %+v", err) + } + return out, nil + } + + out := RawEnableProtectionProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_healtherror.go new file mode 100644 index 00000000000..9b403536983 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go new file mode 100644 index 00000000000..630a66a8c5f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = HyperVReplicaAzureApplyRecoveryPointInput{} + +type HyperVReplicaAzureApplyRecoveryPointInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput +} + +var _ json.Marshaler = HyperVReplicaAzureApplyRecoveryPointInput{} + +func (s HyperVReplicaAzureApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go new file mode 100644 index 00000000000..ed63611334a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVReplicaAzureDiskInputDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go new file mode 100644 index 00000000000..d57f1faad3e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go @@ -0,0 +1,68 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = HyperVReplicaAzureEnableProtectionInput{} + +type HyperVReplicaAzureEnableProtectionInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + DisksToIncludeForManagedDisks *[]HyperVReplicaAzureDiskInputDetails `json:"disksToIncludeForManagedDisks,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + HvHostVMId *string `json:"hvHostVmId,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + OsType *string `json:"osType,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetAzureNetworkId *string `json:"targetAzureNetworkId,omitempty"` + TargetAzureSubnetId *string `json:"targetAzureSubnetId,omitempty"` + TargetAzureV1ResourceGroupId *string `json:"targetAzureV1ResourceGroupId,omitempty"` + TargetAzureV2ResourceGroupId *string `json:"targetAzureV2ResourceGroupId,omitempty"` + TargetAzureVMName *string `json:"targetAzureVmName,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + UseManagedDisksForReplication *string `json:"useManagedDisksForReplication,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput +} + +var _ json.Marshaler = HyperVReplicaAzureEnableProtectionInput{} + +func (s HyperVReplicaAzureEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go new file mode 100644 index 00000000000..d188fac0658 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go @@ -0,0 +1,43 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PlannedFailoverProviderSpecificFailoverInput = HyperVReplicaAzureFailbackProviderInput{} + +type HyperVReplicaAzureFailbackProviderInput struct { + DataSyncOption *string `json:"dataSyncOption,omitempty"` + ProviderIdForAlternateRecovery *string `json:"providerIdForAlternateRecovery,omitempty"` + RecoveryVMCreationOption *string `json:"recoveryVmCreationOption,omitempty"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput +} + +var _ json.Marshaler = HyperVReplicaAzureFailbackProviderInput{} + +func (s HyperVReplicaAzureFailbackProviderInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureFailbackProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzureFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go new file mode 100644 index 00000000000..b4d03b24573 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVReplicaAzureManagedDiskDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + ReplicaDiskType *string `json:"replicaDiskType,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go new file mode 100644 index 00000000000..2ae80dd5540 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go @@ -0,0 +1,44 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PlannedFailoverProviderSpecificFailoverInput = HyperVReplicaAzurePlannedFailoverProviderInput{} + +type HyperVReplicaAzurePlannedFailoverProviderInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput +} + +var _ json.Marshaler = HyperVReplicaAzurePlannedFailoverProviderInput{} + +func (s HyperVReplicaAzurePlannedFailoverProviderInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePlannedFailoverProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go new file mode 100644 index 00000000000..dbc1e231e1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go @@ -0,0 +1,74 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = HyperVReplicaAzureReplicationDetails{} + +type HyperVReplicaAzureReplicationDetails struct { + AllAvailableOSUpgradeConfigurations *[]OSUpgradeSupportedVersions `json:"allAvailableOSUpgradeConfigurations,omitempty"` + AzureVMDiskDetails *[]AzureVMDiskDetails `json:"azureVmDiskDetails,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + Encryption *string `json:"encryption,omitempty"` + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + OSDetails *OSDetails `json:"oSDetails,omitempty"` + ProtectedManagedDisks *[]HyperVReplicaAzureManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureLogStorageAccountId *string `json:"recoveryAzureLogStorageAccountId,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureStorageAccount *string `json:"recoveryAzureStorageAccount,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVmName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = HyperVReplicaAzureReplicationDetails{} + +func (s HyperVReplicaAzureReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go new file mode 100644 index 00000000000..e611c351d80 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go @@ -0,0 +1,46 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = HyperVReplicaAzureReprotectInput{} + +type HyperVReplicaAzureReprotectInput struct { + HvHostVMId *string `json:"hvHostVmId,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + OsType *string `json:"osType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + VHDId *string `json:"vHDId,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput +} + +var _ json.Marshaler = HyperVReplicaAzureReprotectInput{} + +func (s HyperVReplicaAzureReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go new file mode 100644 index 00000000000..c19155908d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go @@ -0,0 +1,44 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = HyperVReplicaAzureTestFailoverInput{} + +type HyperVReplicaAzureTestFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput +} + +var _ json.Marshaler = HyperVReplicaAzureTestFailoverInput{} + +func (s HyperVReplicaAzureTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go new file mode 100644 index 00000000000..f02c6da0c29 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go @@ -0,0 +1,43 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = HyperVReplicaAzureUnplannedFailoverInput{} + +type HyperVReplicaAzureUnplannedFailoverInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput +} + +var _ json.Marshaler = HyperVReplicaAzureUnplannedFailoverInput{} + +func (s HyperVReplicaAzureUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..8daafb5940f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateReplicationProtectedItemProviderInput = HyperVReplicaAzureUpdateReplicationProtectedItemInput{} + +type HyperVReplicaAzureUpdateReplicationProtectedItemInput struct { + DiskIdToDiskEncryptionMap *map[string]string `json:"diskIdToDiskEncryptionMap,omitempty"` + RecoveryAzureV1ResourceGroupId *string `json:"recoveryAzureV1ResourceGroupId,omitempty"` + RecoveryAzureV2ResourceGroupId *string `json:"recoveryAzureV2ResourceGroupId,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VMDisks *[]UpdateDiskInput `json:"vmDisks,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput +} + +var _ json.Marshaler = HyperVReplicaAzureUpdateReplicationProtectedItemInput{} + +func (s HyperVReplicaAzureUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go new file mode 100644 index 00000000000..3422c9c1b70 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go @@ -0,0 +1,47 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = HyperVReplicaBaseReplicationDetails{} + +type HyperVReplicaBaseReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = HyperVReplicaBaseReplicationDetails{} + +func (s HyperVReplicaBaseReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBaseReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaBaseReplicationDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go new file mode 100644 index 00000000000..8eefc928b64 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go @@ -0,0 +1,47 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = HyperVReplicaBlueReplicationDetails{} + +type HyperVReplicaBlueReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = HyperVReplicaBlueReplicationDetails{} + +func (s HyperVReplicaBlueReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBlueReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go new file mode 100644 index 00000000000..5fa220c4dca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go @@ -0,0 +1,47 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = HyperVReplicaReplicationDetails{} + +type HyperVReplicaReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = HyperVReplicaReplicationDetails{} + +func (s HyperVReplicaReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaReplicationDetails: %+v", err) + } + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_initialreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_initialreplicationdetails.go new file mode 100644 index 00000000000..62fc3a51fc8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_initialreplicationdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InitialReplicationDetails struct { + InitialReplicationProgressPercentage *string `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationType *string `json:"initialReplicationType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageagentdetails.go new file mode 100644 index 00000000000..f899ff2af9d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageagentdetails.go @@ -0,0 +1,29 @@ +package replicationprotecteditems + +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 InMageAgentDetails struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentUpdateStatus *string `json:"agentUpdateStatus,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + PostUpdateRebootStatus *string `json:"postUpdateRebootStatus,omitempty"` +} + +func (o *InMageAgentDetails) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAgentDetails) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go new file mode 100644 index 00000000000..5085ebf28bf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = InMageAzureV2ApplyRecoveryPointInput{} + +type InMageAzureV2ApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput +} + +var _ json.Marshaler = InMageAzureV2ApplyRecoveryPointInput{} + +func (s InMageAzureV2ApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go new file mode 100644 index 00000000000..608f4030e29 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2DiskInputDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go new file mode 100644 index 00000000000..9e64f09d6fb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go @@ -0,0 +1,66 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = InMageAzureV2EnableProtectionInput{} + +type InMageAzureV2EnableProtectionInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + DisksToInclude *[]InMageAzureV2DiskInputDetails `json:"disksToInclude,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetAzureNetworkId *string `json:"targetAzureNetworkId,omitempty"` + TargetAzureSubnetId *string `json:"targetAzureSubnetId,omitempty"` + TargetAzureV1ResourceGroupId *string `json:"targetAzureV1ResourceGroupId,omitempty"` + TargetAzureV2ResourceGroupId *string `json:"targetAzureV2ResourceGroupId,omitempty"` + TargetAzureVMName *string `json:"targetAzureVmName,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput +} + +var _ json.Marshaler = InMageAzureV2EnableProtectionInput{} + +func (s InMageAzureV2EnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2EnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go new file mode 100644 index 00000000000..3ee19942044 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2ManagedDiskDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + ReplicaDiskType *string `json:"replicaDiskType,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go new file mode 100644 index 00000000000..95a2304ffef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go @@ -0,0 +1,72 @@ +package replicationprotecteditems + +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 InMageAzureV2ProtectedDiskDetails struct { + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + FileSystemCapacityInBytes *int64 `json:"fileSystemCapacityInBytes,omitempty"` + HealthErrorCode *string `json:"healthErrorCode,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + ProgressHealth *string `json:"progressHealth,omitempty"` + ProgressStatus *string `json:"progressStatus,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + PsDataInMegaBytes *float64 `json:"psDataInMegaBytes,omitempty"` + ResyncDurationInSeconds *int64 `json:"resyncDurationInSeconds,omitempty"` + ResyncLast15MinutesTransferredBytes *int64 `json:"resyncLast15MinutesTransferredBytes,omitempty"` + ResyncLastDataTransferTimeUTC *string `json:"resyncLastDataTransferTimeUTC,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncStartTime *string `json:"resyncStartTime,omitempty"` + ResyncTotalTransferredBytes *int64 `json:"resyncTotalTransferredBytes,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SecondsToTakeSwitchProvider *int64 `json:"secondsToTakeSwitchProvider,omitempty"` + SourceDataInMegaBytes *float64 `json:"sourceDataInMegaBytes,omitempty"` + TargetDataInMegaBytes *float64 `json:"targetDataInMegaBytes,omitempty"` +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetLastRpoCalculatedTimeAsTime() (*time.Time, error) { + if o.LastRpoCalculatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRpoCalculatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetLastRpoCalculatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRpoCalculatedTime = &formatted +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetResyncLastDataTransferTimeUTCAsTime() (*time.Time, error) { + if o.ResyncLastDataTransferTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncLastDataTransferTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetResyncLastDataTransferTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncLastDataTransferTimeUTC = &formatted +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetResyncStartTimeAsTime() (*time.Time, error) { + if o.ResyncStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetResyncStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncStartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go new file mode 100644 index 00000000000..da843844162 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go @@ -0,0 +1,110 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = InMageAzureV2ReplicationDetails{} + +type InMageAzureV2ReplicationDetails struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AllAvailableOSUpgradeConfigurations *[]OSUpgradeSupportedVersions `json:"allAvailableOSUpgradeConfigurations,omitempty"` + AzureVMDiskDetails *[]AzureVMDiskDetails `json:"azureVMDiskDetails,omitempty"` + AzureVMGeneration *string `json:"azureVmGeneration,omitempty"` + CompressedDataRateInMB *float64 `json:"compressedDataRateInMB,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureVMId *string `json:"infrastructureVmId,omitempty"` + IsAdditionalStatsAvailable *bool `json:"isAdditionalStatsAvailable,omitempty"` + IsAgentUpdateRequired *string `json:"isAgentUpdateRequired,omitempty"` + IsRebootAfterUpdateRequired *string `json:"isRebootAfterUpdateRequired,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastUpdateReceivedTime *string `json:"lastUpdateReceivedTime,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + OsDiskId *string `json:"osDiskId,omitempty"` + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProcessServerName *string `json:"processServerName,omitempty"` + ProtectedDisks *[]InMageAzureV2ProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectedManagedDisks *[]InMageAzureV2ManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureLogStorageAccountId *string `json:"recoveryAzureLogStorageAccountId,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureStorageAccount *string `json:"recoveryAzureStorageAccount,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + ReplicaId *string `json:"replicaId,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + SupportedOSVersions *[]string `json:"supportedOSVersions,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageAzureV2SwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` + SwitchProviderDetails *InMageAzureV2SwitchProviderDetails `json:"switchProviderDetails,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMId *string `json:"targetVmId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TotalDataTransferred *int64 `json:"totalDataTransferred,omitempty"` + TotalProgressHealth *string `json:"totalProgressHealth,omitempty"` + UncompressedDataRateInMB *float64 `json:"uncompressedDataRateInMB,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = InMageAzureV2ReplicationDetails{} + +func (s InMageAzureV2ReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ReplicationDetails: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go new file mode 100644 index 00000000000..7acf1b58f0d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go @@ -0,0 +1,47 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = InMageAzureV2ReprotectInput{} + +type InMageAzureV2ReprotectInput struct { + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput +} + +var _ json.Marshaler = InMageAzureV2ReprotectInput{} + +func (s InMageAzureV2ReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ReprotectInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go new file mode 100644 index 00000000000..d8507ad72aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2SwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go new file mode 100644 index 00000000000..5c6e64b3e06 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2SwitchProviderDetails struct { + TargetApplianceId *string `json:"targetApplianceId,omitempty"` + TargetFabricId *string `json:"targetFabricId,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` + TargetVaultId *string `json:"targetVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go new file mode 100644 index 00000000000..2a55685836d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go @@ -0,0 +1,43 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SwitchProviderProviderSpecificInput = InMageAzureV2SwitchProviderProviderInput{} + +type InMageAzureV2SwitchProviderProviderInput struct { + TargetApplianceID string `json:"targetApplianceID"` + TargetFabricID string `json:"targetFabricID"` + TargetVaultID string `json:"targetVaultID"` + + // Fields inherited from SwitchProviderProviderSpecificInput +} + +var _ json.Marshaler = InMageAzureV2SwitchProviderProviderInput{} + +func (s InMageAzureV2SwitchProviderProviderInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2SwitchProviderProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go new file mode 100644 index 00000000000..ff6a69049d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = InMageAzureV2TestFailoverInput{} + +type InMageAzureV2TestFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput +} + +var _ json.Marshaler = InMageAzureV2TestFailoverInput{} + +func (s InMageAzureV2TestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2TestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2TestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2TestFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2TestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go new file mode 100644 index 00000000000..1fb6ca5b171 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = InMageAzureV2UnplannedFailoverInput{} + +type InMageAzureV2UnplannedFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput +} + +var _ json.Marshaler = InMageAzureV2UnplannedFailoverInput{} + +func (s InMageAzureV2UnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2UnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go new file mode 100644 index 00000000000..02552cd40da --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateReplicationProtectedItemProviderInput = InMageAzureV2UpdateReplicationProtectedItemInput{} + +type InMageAzureV2UpdateReplicationProtectedItemInput struct { + RecoveryAzureV1ResourceGroupId *string `json:"recoveryAzureV1ResourceGroupId,omitempty"` + RecoveryAzureV2ResourceGroupId *string `json:"recoveryAzureV2ResourceGroupId,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VMDisks *[]UpdateDiskInput `json:"vmDisks,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput +} + +var _ json.Marshaler = InMageAzureV2UpdateReplicationProtectedItemInput{} + +func (s InMageAzureV2UpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2UpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..5a6d99ee2bd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go @@ -0,0 +1,41 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DisableProtectionProviderSpecificInput = InMageDisableProtectionProviderSpecificInput{} + +type InMageDisableProtectionProviderSpecificInput struct { + ReplicaVMDeletionStatus *string `json:"replicaVmDeletionStatus,omitempty"` + + // Fields inherited from DisableProtectionProviderSpecificInput +} + +var _ json.Marshaler = InMageDisableProtectionProviderSpecificInput{} + +func (s InMageDisableProtectionProviderSpecificInput) MarshalJSON() ([]byte, error) { + type wrapper InMageDisableProtectionProviderSpecificInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagediskexclusioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagediskexclusioninput.go new file mode 100644 index 00000000000..f43893e5555 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagediskexclusioninput.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskExclusionInput struct { + DiskSignatureOptions *[]InMageDiskSignatureExclusionOptions `json:"diskSignatureOptions,omitempty"` + VolumeOptions *[]InMageVolumeExclusionOptions `json:"volumeOptions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go new file mode 100644 index 00000000000..4668154b630 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskSignatureExclusionOptions struct { + DiskSignature *string `json:"diskSignature,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageenableprotectioninput.go new file mode 100644 index 00000000000..846db30cbb8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageenableprotectioninput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = InMageEnableProtectionInput{} + +type InMageEnableProtectionInput struct { + DatastoreName *string `json:"datastoreName,omitempty"` + DiskExclusionInput *InMageDiskExclusionInput `json:"diskExclusionInput,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + MasterTargetId string `json:"masterTargetId"` + MultiVMGroupId string `json:"multiVmGroupId"` + MultiVMGroupName string `json:"multiVmGroupName"` + ProcessServerId string `json:"processServerId"` + RetentionDrive string `json:"retentionDrive"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + VMFriendlyName *string `json:"vmFriendlyName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput +} + +var _ json.Marshaler = InMageEnableProtectionInput{} + +func (s InMageEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageEnableProtectionInput: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go new file mode 100644 index 00000000000..283ba9307e4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +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 InMageProtectedDiskDetails struct { + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + FileSystemCapacityInBytes *int64 `json:"fileSystemCapacityInBytes,omitempty"` + HealthErrorCode *string `json:"healthErrorCode,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + ProgressHealth *string `json:"progressHealth,omitempty"` + ProgressStatus *string `json:"progressStatus,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + PsDataInMB *float64 `json:"psDataInMB,omitempty"` + ResyncDurationInSeconds *int64 `json:"resyncDurationInSeconds,omitempty"` + ResyncLast15MinutesTransferredBytes *int64 `json:"resyncLast15MinutesTransferredBytes,omitempty"` + ResyncLastDataTransferTimeUTC *string `json:"resyncLastDataTransferTimeUTC,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncStartTime *string `json:"resyncStartTime,omitempty"` + ResyncTotalTransferredBytes *int64 `json:"resyncTotalTransferredBytes,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SourceDataInMB *float64 `json:"sourceDataInMB,omitempty"` + TargetDataInMB *float64 `json:"targetDataInMB,omitempty"` +} + +func (o *InMageProtectedDiskDetails) GetLastRpoCalculatedTimeAsTime() (*time.Time, error) { + if o.LastRpoCalculatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRpoCalculatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetLastRpoCalculatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRpoCalculatedTime = &formatted +} + +func (o *InMageProtectedDiskDetails) GetResyncLastDataTransferTimeUTCAsTime() (*time.Time, error) { + if o.ResyncLastDataTransferTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncLastDataTransferTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetResyncLastDataTransferTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncLastDataTransferTimeUTC = &formatted +} + +func (o *InMageProtectedDiskDetails) GetResyncStartTimeAsTime() (*time.Time, error) { + if o.ResyncStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetResyncStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncStartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go new file mode 100644 index 00000000000..6235f92ce41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmAgentUpgradeBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go new file mode 100644 index 00000000000..316da5fb056 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go @@ -0,0 +1,41 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = InMageRcmApplyRecoveryPointInput{} + +type InMageRcmApplyRecoveryPointInput struct { + RecoveryPointId string `json:"recoveryPointId"` + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmApplyRecoveryPointInput{} + +func (s InMageRcmApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go new file mode 100644 index 00000000000..345e3b53683 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go @@ -0,0 +1,61 @@ +package replicationprotecteditems + +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 InMageRcmDiscoveredProtectedVMDetails struct { + CreatedTimestamp *string `json:"createdTimestamp,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + IsDeleted *bool `json:"isDeleted,omitempty"` + LastDiscoveryTimeInUtc *string `json:"lastDiscoveryTimeInUtc,omitempty"` + OsName *string `json:"osName,omitempty"` + PowerStatus *string `json:"powerStatus,omitempty"` + UpdatedTimestamp *string `json:"updatedTimestamp,omitempty"` + VCenterFqdn *string `json:"vCenterFqdn,omitempty"` + VCenterId *string `json:"vCenterId,omitempty"` + VMFqdn *string `json:"vmFqdn,omitempty"` + VMwareToolsStatus *string `json:"vmwareToolsStatus,omitempty"` +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetCreatedTimestampAsTime() (*time.Time, error) { + if o.CreatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetCreatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimestamp = &formatted +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetLastDiscoveryTimeInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetLastDiscoveryTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryTimeInUtc = &formatted +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetUpdatedTimestampAsTime() (*time.Time, error) { + if o.UpdatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetUpdatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedTimestamp = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdiskinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdiskinput.go new file mode 100644 index 00000000000..083eabe8d9a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdiskinput.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmDiskInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId string `json:"diskId"` + DiskType DiskAccountType `json:"diskType"` + LogStorageAccountId string `json:"logStorageAccountId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go new file mode 100644 index 00000000000..64213070d05 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmDisksDefaultInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskType DiskAccountType `json:"diskType"` + LogStorageAccountId string `json:"logStorageAccountId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go new file mode 100644 index 00000000000..aaf09991d81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go @@ -0,0 +1,58 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = InMageRcmEnableProtectionInput{} + +type InMageRcmEnableProtectionInput struct { + DisksDefault *InMageRcmDisksDefaultInput `json:"disksDefault,omitempty"` + DisksToInclude *[]InMageRcmDiskInput `json:"disksToInclude,omitempty"` + FabricDiscoveryMachineId string `json:"fabricDiscoveryMachineId"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ProcessServerId string `json:"processServerId"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId string `json:"targetResourceGroupId"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmEnableProtectionInput{} + +func (s InMageRcmEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmEnableProtectionInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go new file mode 100644 index 00000000000..e90a52a1048 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go @@ -0,0 +1,61 @@ +package replicationprotecteditems + +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 InMageRcmFailbackDiscoveredProtectedVMDetails struct { + CreatedTimestamp *string `json:"createdTimestamp,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + IsDeleted *bool `json:"isDeleted,omitempty"` + LastDiscoveryTimeInUtc *string `json:"lastDiscoveryTimeInUtc,omitempty"` + OsName *string `json:"osName,omitempty"` + PowerStatus *string `json:"powerStatus,omitempty"` + UpdatedTimestamp *string `json:"updatedTimestamp,omitempty"` + VCenterFqdn *string `json:"vCenterFqdn,omitempty"` + VCenterId *string `json:"vCenterId,omitempty"` + VMFqdn *string `json:"vmFqdn,omitempty"` + VMwareToolsStatus *string `json:"vmwareToolsStatus,omitempty"` +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetCreatedTimestampAsTime() (*time.Time, error) { + if o.CreatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetCreatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimestamp = &formatted +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetLastDiscoveryTimeInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetLastDiscoveryTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryTimeInUtc = &formatted +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetUpdatedTimestampAsTime() (*time.Time, error) { + if o.UpdatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetUpdatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedTimestamp = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go new file mode 100644 index 00000000000..6ef3f5e7b37 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go @@ -0,0 +1,58 @@ +package replicationprotecteditems + +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 InMageRcmFailbackMobilityAgentDetails struct { + AgentVersionExpiryDate *string `json:"agentVersionExpiryDate,omitempty"` + DriverVersion *string `json:"driverVersion,omitempty"` + DriverVersionExpiryDate *string `json:"driverVersionExpiryDate,omitempty"` + IsUpgradeable *string `json:"isUpgradeable,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + LatestUpgradableVersionWithoutReboot *string `json:"latestUpgradableVersionWithoutReboot,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + ReasonsBlockingUpgrade *[]AgentUpgradeBlockedReason `json:"reasonsBlockingUpgrade,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetAgentVersionExpiryDateAsTime() (*time.Time, error) { + if o.AgentVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetAgentVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentVersionExpiryDate = &formatted +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetDriverVersionExpiryDateAsTime() (*time.Time, error) { + if o.DriverVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DriverVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetDriverVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DriverVersionExpiryDate = &formatted +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go new file mode 100644 index 00000000000..44ac3499256 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFailbackNicDetails struct { + AdapterType *string `json:"adapterType,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + SourceIPAddress *string `json:"sourceIpAddress,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go new file mode 100644 index 00000000000..4fb7cddae1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go @@ -0,0 +1,41 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PlannedFailoverProviderSpecificFailoverInput = InMageRcmFailbackPlannedFailoverProviderInput{} + +type InMageRcmFailbackPlannedFailoverProviderInput struct { + RecoveryPointType InMageRcmFailbackRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput +} + +var _ json.Marshaler = InMageRcmFailbackPlannedFailoverProviderInput{} + +func (s InMageRcmFailbackPlannedFailoverProviderInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPlannedFailoverProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go new file mode 100644 index 00000000000..0d93a99814a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go @@ -0,0 +1,36 @@ +package replicationprotecteditems + +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 InMageRcmFailbackProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInLogDataStoreInMB *float64 `json:"dataPendingInLogDataStoreInMB,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskUuid *string `json:"diskUuid,omitempty"` + IrDetails *InMageRcmFailbackSyncDetails `json:"irDetails,omitempty"` + IsInitialReplicationComplete *string `json:"isInitialReplicationComplete,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LastSyncTime *string `json:"lastSyncTime,omitempty"` + ResyncDetails *InMageRcmFailbackSyncDetails `json:"resyncDetails,omitempty"` +} + +func (o *InMageRcmFailbackProtectedDiskDetails) GetLastSyncTimeAsTime() (*time.Time, error) { + if o.LastSyncTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSyncTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackProtectedDiskDetails) SetLastSyncTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSyncTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go new file mode 100644 index 00000000000..20af36d13aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go @@ -0,0 +1,69 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = InMageRcmFailbackReplicationDetails{} + +type InMageRcmFailbackReplicationDetails struct { + AzureVirtualMachineId *string `json:"azureVirtualMachineId,omitempty"` + DiscoveredVMDetails *InMageRcmFailbackDiscoveredProtectedVMDetails `json:"discoveredVmDetails,omitempty"` + InitialReplicationProcessedBytes *int64 `json:"initialReplicationProcessedBytes,omitempty"` + InitialReplicationProgressHealth *VMReplicationProgressHealth `json:"initialReplicationProgressHealth,omitempty"` + InitialReplicationProgressPercentage *int64 `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationTransferredBytes *int64 `json:"initialReplicationTransferredBytes,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + IsAgentRegistrationSuccessfulAfterFailover *bool `json:"isAgentRegistrationSuccessfulAfterFailover,omitempty"` + LastPlannedFailoverStartTime *string `json:"lastPlannedFailoverStartTime,omitempty"` + LastPlannedFailoverStatus *PlannedFailoverStatus `json:"lastPlannedFailoverStatus,omitempty"` + LastUsedPolicyFriendlyName *string `json:"lastUsedPolicyFriendlyName,omitempty"` + LastUsedPolicyId *string `json:"lastUsedPolicyId,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MobilityAgentDetails *InMageRcmFailbackMobilityAgentDetails `json:"mobilityAgentDetails,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsType *string `json:"osType,omitempty"` + ProtectedDisks *[]InMageRcmFailbackProtectedDiskDetails `json:"protectedDisks,omitempty"` + ReprotectAgentId *string `json:"reprotectAgentId,omitempty"` + ReprotectAgentName *string `json:"reprotectAgentName,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressHealth *VMReplicationProgressHealth `json:"resyncProgressHealth,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + ResyncTransferredBytes *int64 `json:"resyncTransferredBytes,omitempty"` + TargetDataStoreName *string `json:"targetDataStoreName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetvCenterId *string `json:"targetvCenterId,omitempty"` + VMNics *[]InMageRcmFailbackNicDetails `json:"vmNics,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = InMageRcmFailbackReplicationDetails{} + +func (s InMageRcmFailbackReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go new file mode 100644 index 00000000000..766cbb8d8f6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go @@ -0,0 +1,43 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = InMageRcmFailbackReprotectInput{} + +type InMageRcmFailbackReprotectInput struct { + PolicyId string `json:"policyId"` + ProcessServerId string `json:"processServerId"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmFailbackReprotectInput{} + +func (s InMageRcmFailbackReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackReprotectInput: %+v", err) + } + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go new file mode 100644 index 00000000000..5451ccadcf1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFailbackSyncDetails struct { + Last15MinutesTransferredBytes *int64 `json:"last15MinutesTransferredBytes,omitempty"` + LastDataTransferTimeUtc *string `json:"lastDataTransferTimeUtc,omitempty"` + LastRefreshTime *string `json:"lastRefreshTime,omitempty"` + ProcessedBytes *int64 `json:"processedBytes,omitempty"` + ProgressHealth *DiskReplicationProgressHealth `json:"progressHealth,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TransferredBytes *int64 `json:"transferredBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go new file mode 100644 index 00000000000..8e87e3b48bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmLastAgentUpgradeErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go new file mode 100644 index 00000000000..bc2431c22ae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go @@ -0,0 +1,59 @@ +package replicationprotecteditems + +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 InMageRcmMobilityAgentDetails struct { + AgentVersionExpiryDate *string `json:"agentVersionExpiryDate,omitempty"` + DriverVersion *string `json:"driverVersion,omitempty"` + DriverVersionExpiryDate *string `json:"driverVersionExpiryDate,omitempty"` + IsUpgradeable *string `json:"isUpgradeable,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + LatestAgentReleaseDate *string `json:"latestAgentReleaseDate,omitempty"` + LatestUpgradableVersionWithoutReboot *string `json:"latestUpgradableVersionWithoutReboot,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + ReasonsBlockingUpgrade *[]AgentUpgradeBlockedReason `json:"reasonsBlockingUpgrade,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *InMageRcmMobilityAgentDetails) GetAgentVersionExpiryDateAsTime() (*time.Time, error) { + if o.AgentVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetAgentVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentVersionExpiryDate = &formatted +} + +func (o *InMageRcmMobilityAgentDetails) GetDriverVersionExpiryDateAsTime() (*time.Time, error) { + if o.DriverVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DriverVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetDriverVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DriverVersionExpiryDate = &formatted +} + +func (o *InMageRcmMobilityAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmnicdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmnicdetails.go new file mode 100644 index 00000000000..83396d6b89e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmnicdetails.go @@ -0,0 +1,20 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmNicDetails struct { + IsPrimaryNic *string `json:"isPrimaryNic,omitempty"` + IsSelectedForFailover *string `json:"isSelectedForFailover,omitempty"` + NicId *string `json:"nicId,omitempty"` + SourceIPAddress *string `json:"sourceIPAddress,omitempty"` + SourceIPAddressType *EthernetAddressType `json:"sourceIPAddressType,omitempty"` + SourceNetworkId *string `json:"sourceNetworkId,omitempty"` + SourceSubnetName *string `json:"sourceSubnetName,omitempty"` + TargetIPAddress *string `json:"targetIPAddress,omitempty"` + TargetIPAddressType *EthernetAddressType `json:"targetIPAddressType,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestIPAddress *string `json:"testIPAddress,omitempty"` + TestIPAddressType *EthernetAddressType `json:"testIPAddressType,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmnicinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmnicinput.go new file mode 100644 index 00000000000..552bb0d12d7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmnicinput.go @@ -0,0 +1,14 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmNicInput struct { + IsPrimaryNic string `json:"isPrimaryNic"` + IsSelectedForFailover *string `json:"isSelectedForFailover,omitempty"` + NicId string `json:"nicId"` + TargetStaticIPAddress *string `json:"targetStaticIPAddress,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestStaticIPAddress *string `json:"testStaticIPAddress,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go new file mode 100644 index 00000000000..c592b09c3dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go @@ -0,0 +1,22 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInLogDataStoreInMB *float64 `json:"dataPendingInLogDataStoreInMB,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + IrDetails *InMageRcmSyncDetails `json:"irDetails,omitempty"` + IsInitialReplicationComplete *string `json:"isInitialReplicationComplete,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + ResyncDetails *InMageRcmSyncDetails `json:"resyncDetails,omitempty"` + SeedBlobUri *string `json:"seedBlobUri,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetManagedDiskId *string `json:"targetManagedDiskId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmreplicationdetails.go new file mode 100644 index 00000000000..8d8f494fcff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmreplicationdetails.go @@ -0,0 +1,92 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = InMageRcmReplicationDetails{} + +type InMageRcmReplicationDetails struct { + AgentUpgradeAttemptToVersion *string `json:"agentUpgradeAttemptToVersion,omitempty"` + AgentUpgradeBlockingErrorDetails *[]InMageRcmAgentUpgradeBlockingErrorDetails `json:"agentUpgradeBlockingErrorDetails,omitempty"` + AgentUpgradeJobId *string `json:"agentUpgradeJobId,omitempty"` + AgentUpgradeState *MobilityAgentUpgradeState `json:"agentUpgradeState,omitempty"` + AllocatedMemoryInMB *float64 `json:"allocatedMemoryInMB,omitempty"` + DiscoveredVMDetails *InMageRcmDiscoveredProtectedVMDetails `json:"discoveredVmDetails,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + FabricDiscoveryMachineId *string `json:"fabricDiscoveryMachineId,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + InitialReplicationProcessedBytes *int64 `json:"initialReplicationProcessedBytes,omitempty"` + InitialReplicationProgressHealth *VMReplicationProgressHealth `json:"initialReplicationProgressHealth,omitempty"` + InitialReplicationProgressPercentage *int64 `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationTransferredBytes *int64 `json:"initialReplicationTransferredBytes,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + IsAgentRegistrationSuccessfulAfterFailover *bool `json:"isAgentRegistrationSuccessfulAfterFailover,omitempty"` + IsLastUpgradeSuccessful *string `json:"isLastUpgradeSuccessful,omitempty"` + LastAgentUpgradeErrorDetails *[]InMageRcmLastAgentUpgradeErrorDetails `json:"lastAgentUpgradeErrorDetails,omitempty"` + LastAgentUpgradeType *string `json:"lastAgentUpgradeType,omitempty"` + LastRecoveryPointId *string `json:"lastRecoveryPointId,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastRpoInSeconds *int64 `json:"lastRpoInSeconds,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + MobilityAgentDetails *InMageRcmMobilityAgentDetails `json:"mobilityAgentDetails,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryNicIPAddress *string `json:"primaryNicIpAddress,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProcessServerName *string `json:"processServerName,omitempty"` + ProcessorCoreCount *int64 `json:"processorCoreCount,omitempty"` + ProtectedDisks *[]InMageRcmProtectedDiskDetails `json:"protectedDisks,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressHealth *VMReplicationProgressHealth `json:"resyncProgressHealth,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + ResyncTransferredBytes *int64 `json:"resyncTransferredBytes,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetGeneration *string `json:"targetGeneration,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + VMNics *[]InMageRcmNicDetails `json:"vmNics,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = InMageRcmReplicationDetails{} + +func (s InMageRcmReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmReplicationDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmreprotectinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmreprotectinput.go new file mode 100644 index 00000000000..f36bee34a6c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmreprotectinput.go @@ -0,0 +1,44 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = InMageRcmReprotectInput{} + +type InMageRcmReprotectInput struct { + DatastoreName string `json:"datastoreName"` + LogStorageAccountId string `json:"logStorageAccountId"` + PolicyId *string `json:"policyId,omitempty"` + ReprotectAgentId string `json:"reprotectAgentId"` + + // Fields inherited from ReverseReplicationProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmReprotectInput{} + +func (s InMageRcmReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmReprotectInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmsyncdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmsyncdetails.go new file mode 100644 index 00000000000..a8388f3c5f8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmsyncdetails.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmSyncDetails struct { + Last15MinutesTransferredBytes *int64 `json:"last15MinutesTransferredBytes,omitempty"` + LastDataTransferTimeUtc *string `json:"lastDataTransferTimeUtc,omitempty"` + LastRefreshTime *string `json:"lastRefreshTime,omitempty"` + ProcessedBytes *int64 `json:"processedBytes,omitempty"` + ProgressHealth *DiskReplicationProgressHealth `json:"progressHealth,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TransferredBytes *int64 `json:"transferredBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go new file mode 100644 index 00000000000..4f3264c0859 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = InMageRcmTestFailoverInput{} + +type InMageRcmTestFailoverInput struct { + NetworkId *string `json:"networkId,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmTestFailoverInput{} + +func (s InMageRcmTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmTestFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go new file mode 100644 index 00000000000..688ddd4e9f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = InMageRcmUnplannedFailoverInput{} + +type InMageRcmUnplannedFailoverInput struct { + PerformShutdown string `json:"performShutdown"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmUnplannedFailoverInput{} + +func (s InMageRcmUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go new file mode 100644 index 00000000000..59a0e19cd4a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go @@ -0,0 +1,41 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateApplianceForReplicationProtectedItemProviderSpecificInput = InMageRcmUpdateApplianceForReplicationProtectedItemInput{} + +type InMageRcmUpdateApplianceForReplicationProtectedItemInput struct { + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from UpdateApplianceForReplicationProtectedItemProviderSpecificInput +} + +var _ json.Marshaler = InMageRcmUpdateApplianceForReplicationProtectedItemInput{} + +func (s InMageRcmUpdateApplianceForReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateApplianceForReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..428a0dc1aeb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateReplicationProtectedItemProviderInput = InMageRcmUpdateReplicationProtectedItemInput{} + +type InMageRcmUpdateReplicationProtectedItemInput struct { + LicenseType *LicenseType `json:"licenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + VMNics *[]InMageRcmNicInput `json:"vmNics,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput +} + +var _ json.Marshaler = InMageRcmUpdateReplicationProtectedItemInput{} + +func (s InMageRcmUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagereplicationdetails.go new file mode 100644 index 00000000000..b12af712d38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagereplicationdetails.go @@ -0,0 +1,80 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = InMageReplicationDetails{} + +type InMageReplicationDetails struct { + ActiveSiteType *string `json:"activeSiteType,omitempty"` + AgentDetails *InMageAgentDetails `json:"agentDetails,omitempty"` + AzureStorageAccountId *string `json:"azureStorageAccountId,omitempty"` + CompressedDataRateInMB *float64 `json:"compressedDataRateInMB,omitempty"` + ConsistencyPoints *map[string]string `json:"consistencyPoints,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureVMId *string `json:"infrastructureVmId,omitempty"` + IsAdditionalStatsAvailable *bool `json:"isAdditionalStatsAvailable,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastUpdateReceivedTime *string `json:"lastUpdateReceivedTime,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + OsDetails *OSDiskDetails `json:"osDetails,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProtectedDisks *[]InMageProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + RebootAfterUpdateStatus *string `json:"rebootAfterUpdateStatus,omitempty"` + ReplicaId *string `json:"replicaId,omitempty"` + ResyncDetails *InitialReplicationDetails `json:"resyncDetails,omitempty"` + RetentionWindowEnd *string `json:"retentionWindowEnd,omitempty"` + RetentionWindowStart *string `json:"retentionWindowStart,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + TotalDataTransferred *int64 `json:"totalDataTransferred,omitempty"` + TotalProgressHealth *string `json:"totalProgressHealth,omitempty"` + UncompressedDataRateInMB *float64 `json:"uncompressedDataRateInMB,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings +} + +var _ json.Marshaler = InMageReplicationDetails{} + +func (s InMageReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageReplicationDetails: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagereprotectinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagereprotectinput.go new file mode 100644 index 00000000000..8ed97d029c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagereprotectinput.go @@ -0,0 +1,48 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = InMageReprotectInput{} + +type InMageReprotectInput struct { + DatastoreName *string `json:"datastoreName,omitempty"` + DiskExclusionInput *InMageDiskExclusionInput `json:"diskExclusionInput,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + MasterTargetId string `json:"masterTargetId"` + ProcessServerId string `json:"processServerId"` + ProfileId string `json:"profileId"` + RetentionDrive string `json:"retentionDrive"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput +} + +var _ json.Marshaler = InMageReprotectInput{} + +func (s InMageReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageReprotectInput: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagetestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagetestfailoverinput.go new file mode 100644 index 00000000000..68347d06749 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagetestfailoverinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = InMageTestFailoverInput{} + +type InMageTestFailoverInput struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointType *RecoveryPointType `json:"recoveryPointType,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput +} + +var _ json.Marshaler = InMageTestFailoverInput{} + +func (s InMageTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageTestFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go new file mode 100644 index 00000000000..e03da157307 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = InMageUnplannedFailoverInput{} + +type InMageUnplannedFailoverInput struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointType *RecoveryPointType `json:"recoveryPointType,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput +} + +var _ json.Marshaler = InMageUnplannedFailoverInput{} + +func (s InMageUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageUnplannedFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go new file mode 100644 index 00000000000..f8a523a289d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageVolumeExclusionOptions struct { + OnlyExcludeIfSingleVolume *string `json:"onlyExcludeIfSingleVolume,omitempty"` + VolumeLabel *string `json:"volumeLabel,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_innerhealtherror.go new file mode 100644 index 00000000000..dc06e717b80 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotecteditems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inputendpoint.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inputendpoint.go new file mode 100644 index 00000000000..a0e3fd45e70 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_inputendpoint.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InputEndpoint struct { + EndpointName *string `json:"endpointName,omitempty"` + PrivatePort *int64 `json:"privatePort,omitempty"` + Protocol *string `json:"protocol,omitempty"` + PublicPort *int64 `json:"publicPort,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_ipconfigdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_ipconfigdetails.go new file mode 100644 index 00000000000..74ce87533d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_ipconfigdetails.go @@ -0,0 +1,22 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigDetails struct { + IPAddressType *string `json:"ipAddressType,omitempty"` + IsPrimary *bool `json:"isPrimary,omitempty"` + IsSeletedForFailover *bool `json:"isSeletedForFailover,omitempty"` + Name *string `json:"name,omitempty"` + RecoveryIPAddressType *string `json:"recoveryIPAddressType,omitempty"` + RecoveryLBBackendAddressPoolIds *[]string `json:"recoveryLBBackendAddressPoolIds,omitempty"` + RecoveryPublicIPAddressId *string `json:"recoveryPublicIPAddressId,omitempty"` + RecoveryStaticIPAddress *string `json:"recoveryStaticIPAddress,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + StaticIPAddress *string `json:"staticIPAddress,omitempty"` + SubnetName *string `json:"subnetName,omitempty"` + TfoLBBackendAddressPoolIds *[]string `json:"tfoLBBackendAddressPoolIds,omitempty"` + TfoPublicIPAddressId *string `json:"tfoPublicIPAddressId,omitempty"` + TfoStaticIPAddress *string `json:"tfoStaticIPAddress,omitempty"` + TfoSubnetName *string `json:"tfoSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_ipconfiginputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_ipconfiginputdetails.go new file mode 100644 index 00000000000..de0609e9a0d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_ipconfiginputdetails.go @@ -0,0 +1,18 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigInputDetails struct { + IPConfigName *string `json:"ipConfigName,omitempty"` + IsPrimary *bool `json:"isPrimary,omitempty"` + IsSeletedForFailover *bool `json:"isSeletedForFailover,omitempty"` + RecoveryLBBackendAddressPoolIds *[]string `json:"recoveryLBBackendAddressPoolIds,omitempty"` + RecoveryPublicIPAddressId *string `json:"recoveryPublicIPAddressId,omitempty"` + RecoveryStaticIPAddress *string `json:"recoveryStaticIPAddress,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + TfoLBBackendAddressPoolIds *[]string `json:"tfoLBBackendAddressPoolIds,omitempty"` + TfoPublicIPAddressId *string `json:"tfoPublicIPAddressId,omitempty"` + TfoStaticIPAddress *string `json:"tfoStaticIPAddress,omitempty"` + TfoSubnetName *string `json:"tfoSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..b0d163a1195 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osdetails.go new file mode 100644 index 00000000000..ffe22cbffdc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osdetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDetails struct { + OSMajorVersion *string `json:"oSMajorVersion,omitempty"` + OSMinorVersion *string `json:"oSMinorVersion,omitempty"` + OSVersion *string `json:"oSVersion,omitempty"` + OsEdition *string `json:"osEdition,omitempty"` + OsType *string `json:"osType,omitempty"` + ProductType *string `json:"productType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osdiskdetails.go new file mode 100644 index 00000000000..9686e06d452 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osdiskdetails.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDiskDetails struct { + OsType *string `json:"osType,omitempty"` + OsVhdId *string `json:"osVhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osupgradesupportedversions.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osupgradesupportedversions.go new file mode 100644 index 00000000000..c67f7c6cdc9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_osupgradesupportedversions.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSUpgradeSupportedVersions struct { + SupportedSourceOsVersion *string `json:"supportedSourceOsVersion,omitempty"` + SupportedTargetOsVersions *[]string `json:"supportedTargetOsVersions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverinput.go new file mode 100644 index 00000000000..ccf7d67c6ad --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlannedFailoverInput struct { + Properties *PlannedFailoverInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverinputproperties.go new file mode 100644 index 00000000000..4a6bb1dae0a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverinputproperties.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/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 PlannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails PlannedFailoverProviderSpecificFailoverInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &PlannedFailoverInputProperties{} + +func (s *PlannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + type alias PlannedFailoverInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into PlannedFailoverInputProperties: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PlannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalPlannedFailoverProviderSpecificFailoverInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'PlannedFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go new file mode 100644 index 00000000000..4371a17a202 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go @@ -0,0 +1,69 @@ +package replicationprotecteditems + +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 PlannedFailoverProviderSpecificFailoverInput interface { +} + +// RawPlannedFailoverProviderSpecificFailoverInputImpl 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 RawPlannedFailoverProviderSpecificFailoverInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalPlannedFailoverProviderSpecificFailoverInputImplementation(input []byte) (PlannedFailoverProviderSpecificFailoverInput, 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 PlannedFailoverProviderSpecificFailoverInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzureFailback") { + var out HyperVReplicaAzureFailbackProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePlannedFailoverProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPlannedFailoverProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + return out, nil + } + + out := RawPlannedFailoverProviderSpecificFailoverInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksinput.go new file mode 100644 index 00000000000..bfb58b0e932 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveDisksInput struct { + Properties *RemoveDisksInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksinputproperties.go new file mode 100644 index 00000000000..eb805049101 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksinputproperties.go @@ -0,0 +1,32 @@ +package replicationprotecteditems + +import ( + "encoding/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 RemoveDisksInputProperties struct { + ProviderSpecificDetails RemoveDisksProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &RemoveDisksInputProperties{} + +func (s *RemoveDisksInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RemoveDisksInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalRemoveDisksProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'RemoveDisksInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksproviderspecificinput.go new file mode 100644 index 00000000000..73a0e3c6b4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_removedisksproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 RemoveDisksProviderSpecificInput interface { +} + +// RawRemoveDisksProviderSpecificInputImpl 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 RawRemoveDisksProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRemoveDisksProviderSpecificInputImplementation(input []byte) (RemoveDisksProviderSpecificInput, 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 RemoveDisksProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2ARemoveDisksInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ARemoveDisksInput: %+v", err) + } + return out, nil + } + + out := RawRemoveDisksProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationprotecteditem.go new file mode 100644 index 00000000000..8c86ba791a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationprotecteditem.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectedItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationProtectedItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationprotecteditemproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationprotecteditemproperties.go new file mode 100644 index 00000000000..fcf1010f232 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationprotecteditemproperties.go @@ -0,0 +1,123 @@ +package replicationprotecteditems + +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. + +type ReplicationProtectedItemProperties struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + FailoverHealth *string `json:"failoverHealth,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + ProtectedItemType *string `json:"protectedItemType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + ProviderSpecificDetails ReplicationProviderSpecificSettings `json:"providerSpecificDetails"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SwitchProviderState *string `json:"switchProviderState,omitempty"` + SwitchProviderStateDescription *string `json:"switchProviderStateDescription,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` +} + +func (o *ReplicationProtectedItemProperties) GetLastSuccessfulFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectedItemProperties) SetLastSuccessfulFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulFailoverTime = &formatted +} + +func (o *ReplicationProtectedItemProperties) GetLastSuccessfulTestFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulTestFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulTestFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectedItemProperties) SetLastSuccessfulTestFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulTestFailoverTime = &formatted +} + +var _ json.Unmarshaler = &ReplicationProtectedItemProperties{} + +func (s *ReplicationProtectedItemProperties) UnmarshalJSON(bytes []byte) error { + type alias ReplicationProtectedItemProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ReplicationProtectedItemProperties: %+v", err) + } + + s.ActiveLocation = decoded.ActiveLocation + s.AllowedOperations = decoded.AllowedOperations + s.CurrentScenario = decoded.CurrentScenario + s.EventCorrelationId = decoded.EventCorrelationId + s.FailoverHealth = decoded.FailoverHealth + s.FailoverRecoveryPointId = decoded.FailoverRecoveryPointId + s.FriendlyName = decoded.FriendlyName + s.HealthErrors = decoded.HealthErrors + s.LastSuccessfulFailoverTime = decoded.LastSuccessfulFailoverTime + s.LastSuccessfulTestFailoverTime = decoded.LastSuccessfulTestFailoverTime + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryFabricProvider = decoded.PrimaryFabricProvider + s.PrimaryProtectionContainerFriendlyName = decoded.PrimaryProtectionContainerFriendlyName + s.ProtectableItemId = decoded.ProtectableItemId + s.ProtectedItemType = decoded.ProtectedItemType + s.ProtectionState = decoded.ProtectionState + s.ProtectionStateDescription = decoded.ProtectionStateDescription + s.RecoveryContainerId = decoded.RecoveryContainerId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryFabricId = decoded.RecoveryFabricId + s.RecoveryProtectionContainerFriendlyName = decoded.RecoveryProtectionContainerFriendlyName + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationHealth = decoded.ReplicationHealth + s.SwitchProviderState = decoded.SwitchProviderState + s.SwitchProviderStateDescription = decoded.SwitchProviderStateDescription + s.TestFailoverState = decoded.TestFailoverState + s.TestFailoverStateDescription = decoded.TestFailoverStateDescription + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationProtectedItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalReplicationProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationProtectedItemProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationproviderspecificsettings.go new file mode 100644 index 00000000000..1e5be9a6f91 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_replicationproviderspecificsettings.go @@ -0,0 +1,125 @@ +package replicationprotecteditems + +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 ReplicationProviderSpecificSettings interface { +} + +// RawReplicationProviderSpecificSettingsImpl 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 RawReplicationProviderSpecificSettingsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalReplicationProviderSpecificSettingsImplementation(input []byte) (ReplicationProviderSpecificSettings, 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 ReplicationProviderSpecificSettings into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBaseReplicationDetails") { + var out HyperVReplicaBaseReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBaseReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplicaBlueReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBlueReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageReplicationDetails: %+v", err) + } + return out, nil + } + + out := RawReplicationProviderSpecificSettingsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealtherror.go new file mode 100644 index 00000000000..0fc7181b7ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealtherror.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthError struct { + HealthErrorId *string `json:"healthErrorId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealthinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealthinput.go new file mode 100644 index 00000000000..57ce7884f4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealthinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthInput struct { + Properties *ResolveHealthInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealthinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealthinputproperties.go new file mode 100644 index 00000000000..735fbf2ee53 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_resolvehealthinputproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthInputProperties struct { + HealthErrors *[]ResolveHealthError `json:"healthErrors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationinput.go new file mode 100644 index 00000000000..dcd65ebb176 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReverseReplicationInput struct { + Properties *ReverseReplicationInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationinputproperties.go new file mode 100644 index 00000000000..9d4d4c1da7f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationinputproperties.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/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 ReverseReplicationInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails ReverseReplicationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReverseReplicationInputProperties{} + +func (s *ReverseReplicationInputProperties) UnmarshalJSON(bytes []byte) error { + type alias ReverseReplicationInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ReverseReplicationInputProperties: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReverseReplicationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalReverseReplicationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReverseReplicationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go new file mode 100644 index 00000000000..551d56de914 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go @@ -0,0 +1,93 @@ +package replicationprotecteditems + +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 ReverseReplicationProviderSpecificInput interface { +} + +// RawReverseReplicationProviderSpecificInputImpl 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 RawReverseReplicationProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalReverseReplicationProviderSpecificInputImplementation(input []byte) (ReverseReplicationProviderSpecificInput, 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 ReverseReplicationProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageReprotectInput: %+v", err) + } + return out, nil + } + + out := RawReverseReplicationProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderinput.go new file mode 100644 index 00000000000..701b7dcfb6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProviderInput struct { + Properties *SwitchProviderInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderinputproperties.go new file mode 100644 index 00000000000..86770b49b74 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderinputproperties.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/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 SwitchProviderInputProperties struct { + ProviderSpecificDetails SwitchProviderProviderSpecificInput `json:"providerSpecificDetails"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` +} + +var _ json.Unmarshaler = &SwitchProviderInputProperties{} + +func (s *SwitchProviderInputProperties) UnmarshalJSON(bytes []byte) error { + type alias SwitchProviderInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into SwitchProviderInputProperties: %+v", err) + } + + s.TargetInstanceType = decoded.TargetInstanceType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SwitchProviderInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalSwitchProviderProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'SwitchProviderInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go new file mode 100644 index 00000000000..fc9fa51e0bf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 SwitchProviderProviderSpecificInput interface { +} + +// RawSwitchProviderProviderSpecificInputImpl 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 RawSwitchProviderProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalSwitchProviderProviderSpecificInputImplementation(input []byte) (SwitchProviderProviderSpecificInput, 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 SwitchProviderProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2SwitchProviderProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + return out, nil + } + + out := RawSwitchProviderProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailovercleanupinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailovercleanupinput.go new file mode 100644 index 00000000000..29c6eb3256b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailovercleanupinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupInput struct { + Properties TestFailoverCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go new file mode 100644 index 00000000000..9699a278467 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverinput.go new file mode 100644 index 00000000000..88eb28a5898 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverInput struct { + Properties TestFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverinputproperties.go new file mode 100644 index 00000000000..098e800430b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverinputproperties.go @@ -0,0 +1,44 @@ +package replicationprotecteditems + +import ( + "encoding/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 TestFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProviderSpecificDetails TestFailoverProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &TestFailoverInputProperties{} + +func (s *TestFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + type alias TestFailoverInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into TestFailoverInputProperties: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.NetworkId = decoded.NetworkId + s.NetworkType = decoded.NetworkType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TestFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalTestFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'TestFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go new file mode 100644 index 00000000000..a9a345c2fa9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go @@ -0,0 +1,85 @@ +package replicationprotecteditems + +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 TestFailoverProviderSpecificInput interface { +} + +// RawTestFailoverProviderSpecificInputImpl 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 RawTestFailoverProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalTestFailoverProviderSpecificInputImplementation(input []byte) (TestFailoverProviderSpecificInput, 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 TestFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2ATestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ATestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureTestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2TestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2TestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmTestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageTestFailoverInput: %+v", err) + } + return out, nil + } + + out := RawTestFailoverProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverinput.go new file mode 100644 index 00000000000..12ae4f94f48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverInput struct { + Properties UnplannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go new file mode 100644 index 00000000000..b998698389d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/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 UnplannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails UnplannedFailoverProviderSpecificInput `json:"providerSpecificDetails"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` +} + +var _ json.Unmarshaler = &UnplannedFailoverInputProperties{} + +func (s *UnplannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + type alias UnplannedFailoverInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into UnplannedFailoverInputProperties: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.SourceSiteOperations = decoded.SourceSiteOperations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UnplannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalUnplannedFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UnplannedFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go new file mode 100644 index 00000000000..e1270ba432e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go @@ -0,0 +1,85 @@ +package replicationprotecteditems + +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 UnplannedFailoverProviderSpecificInput interface { +} + +// RawUnplannedFailoverProviderSpecificInputImpl 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 RawUnplannedFailoverProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalUnplannedFailoverProviderSpecificInputImplementation(input []byte) (UnplannedFailoverProviderSpecificInput, 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 UnplannedFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2UnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2UnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + out := RawUnplannedFailoverProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go new file mode 100644 index 00000000000..8bb8dbd243c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateApplianceForReplicationProtectedItemInput struct { + Properties UpdateApplianceForReplicationProtectedItemInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go new file mode 100644 index 00000000000..a1073c0228c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +import ( + "encoding/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 UpdateApplianceForReplicationProtectedItemInputProperties struct { + ProviderSpecificDetails UpdateApplianceForReplicationProtectedItemProviderSpecificInput `json:"providerSpecificDetails"` + TargetApplianceId string `json:"targetApplianceId"` +} + +var _ json.Unmarshaler = &UpdateApplianceForReplicationProtectedItemInputProperties{} + +func (s *UpdateApplianceForReplicationProtectedItemInputProperties) UnmarshalJSON(bytes []byte) error { + type alias UpdateApplianceForReplicationProtectedItemInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into UpdateApplianceForReplicationProtectedItemInputProperties: %+v", err) + } + + s.TargetApplianceId = decoded.TargetApplianceId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateApplianceForReplicationProtectedItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalUpdateApplianceForReplicationProtectedItemProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateApplianceForReplicationProtectedItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go new file mode 100644 index 00000000000..4ecaa33309c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 UpdateApplianceForReplicationProtectedItemProviderSpecificInput interface { +} + +// RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl 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 RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalUpdateApplianceForReplicationProtectedItemProviderSpecificInputImplementation(input []byte) (UpdateApplianceForReplicationProtectedItemProviderSpecificInput, 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 UpdateApplianceForReplicationProtectedItemProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateApplianceForReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + out := RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatediskinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatediskinput.go new file mode 100644 index 00000000000..89c2747dd8b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatediskinput.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDiskInput struct { + DiskId string `json:"diskId"` + TargetDiskName *string `json:"targetDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatemobilityservicerequest.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatemobilityservicerequest.go new file mode 100644 index 00000000000..88df4c561c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatemobilityservicerequest.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMobilityServiceRequest struct { + Properties *UpdateMobilityServiceRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go new file mode 100644 index 00000000000..bc5afdc6871 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMobilityServiceRequestProperties struct { + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go new file mode 100644 index 00000000000..6a33ddab87b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateReplicationProtectedItemInput struct { + Properties *UpdateReplicationProtectedItemInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go new file mode 100644 index 00000000000..ce7313ff7b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +import ( + "encoding/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 UpdateReplicationProtectedItemInputProperties struct { + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + ProviderSpecificDetails UpdateReplicationProtectedItemProviderInput `json:"providerSpecificDetails"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + VMNics *[]VMNicInputDetails `json:"vmNics,omitempty"` +} + +var _ json.Unmarshaler = &UpdateReplicationProtectedItemInputProperties{} + +func (s *UpdateReplicationProtectedItemInputProperties) UnmarshalJSON(bytes []byte) error { + type alias UpdateReplicationProtectedItemInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into UpdateReplicationProtectedItemInputProperties: %+v", err) + } + + s.EnableRdpOnTargetOption = decoded.EnableRdpOnTargetOption + s.LicenseType = decoded.LicenseType + s.RecoveryAvailabilitySetId = decoded.RecoveryAvailabilitySetId + s.RecoveryAzureVMName = decoded.RecoveryAzureVMName + s.RecoveryAzureVMSize = decoded.RecoveryAzureVMSize + s.SelectedRecoveryAzureNetworkId = decoded.SelectedRecoveryAzureNetworkId + s.SelectedSourceNicId = decoded.SelectedSourceNicId + s.SelectedTfoAzureNetworkId = decoded.SelectedTfoAzureNetworkId + s.VMNics = decoded.VMNics + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateReplicationProtectedItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalUpdateReplicationProtectedItemProviderInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateReplicationProtectedItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go new file mode 100644 index 00000000000..e890f834bde --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go @@ -0,0 +1,77 @@ +package replicationprotecteditems + +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 UpdateReplicationProtectedItemProviderInput interface { +} + +// RawUpdateReplicationProtectedItemProviderInputImpl 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 RawUpdateReplicationProtectedItemProviderInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalUpdateReplicationProtectedItemProviderInputImplementation(input []byte) (UpdateReplicationProtectedItemProviderInput, 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 UpdateReplicationProtectedItemProviderInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2UpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + out := RawUpdateReplicationProtectedItemProviderInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_vmnicdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_vmnicdetails.go new file mode 100644 index 00000000000..aa704f28341 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_vmnicdetails.go @@ -0,0 +1,26 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMNicDetails struct { + EnableAcceleratedNetworkingOnRecovery *bool `json:"enableAcceleratedNetworkingOnRecovery,omitempty"` + EnableAcceleratedNetworkingOnTfo *bool `json:"enableAcceleratedNetworkingOnTfo,omitempty"` + IPConfigs *[]IPConfigDetails `json:"ipConfigs,omitempty"` + NicId *string `json:"nicId,omitempty"` + RecoveryNetworkSecurityGroupId *string `json:"recoveryNetworkSecurityGroupId,omitempty"` + RecoveryNicName *string `json:"recoveryNicName,omitempty"` + RecoveryNicResourceGroupName *string `json:"recoveryNicResourceGroupName,omitempty"` + RecoveryVMNetworkId *string `json:"recoveryVMNetworkId,omitempty"` + ReplicaNicId *string `json:"replicaNicId,omitempty"` + ReuseExistingNic *bool `json:"reuseExistingNic,omitempty"` + SelectionType *string `json:"selectionType,omitempty"` + SourceNicArmId *string `json:"sourceNicArmId,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TfoNetworkSecurityGroupId *string `json:"tfoNetworkSecurityGroupId,omitempty"` + TfoRecoveryNicName *string `json:"tfoRecoveryNicName,omitempty"` + TfoRecoveryNicResourceGroupName *string `json:"tfoRecoveryNicResourceGroupName,omitempty"` + TfoReuseExistingNic *bool `json:"tfoReuseExistingNic,omitempty"` + TfoVMNetworkId *string `json:"tfoVMNetworkId,omitempty"` + VMNetworkName *string `json:"vMNetworkName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_vmnicinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_vmnicinputdetails.go new file mode 100644 index 00000000000..7c18c51a759 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/model_vmnicinputdetails.go @@ -0,0 +1,21 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMNicInputDetails struct { + EnableAcceleratedNetworkingOnRecovery *bool `json:"enableAcceleratedNetworkingOnRecovery,omitempty"` + EnableAcceleratedNetworkingOnTfo *bool `json:"enableAcceleratedNetworkingOnTfo,omitempty"` + IPConfigs *[]IPConfigInputDetails `json:"ipConfigs,omitempty"` + NicId *string `json:"nicId,omitempty"` + RecoveryNetworkSecurityGroupId *string `json:"recoveryNetworkSecurityGroupId,omitempty"` + RecoveryNicName *string `json:"recoveryNicName,omitempty"` + RecoveryNicResourceGroupName *string `json:"recoveryNicResourceGroupName,omitempty"` + ReuseExistingNic *bool `json:"reuseExistingNic,omitempty"` + SelectionType *string `json:"selectionType,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TfoNetworkSecurityGroupId *string `json:"tfoNetworkSecurityGroupId,omitempty"` + TfoNicName *string `json:"tfoNicName,omitempty"` + TfoNicResourceGroupName *string `json:"tfoNicResourceGroupName,omitempty"` + TfoReuseExistingNic *bool `json:"tfoReuseExistingNic,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/predicates.go new file mode 100644 index 00000000000..533da5b6f5e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/predicates.go @@ -0,0 +1,32 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectedItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ReplicationProtectedItemOperationPredicate) Matches(input ReplicationProtectedItem) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/version.go new file mode 100644 index 00000000000..92a953b775a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotecteditems/version.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationprotecteditems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/README.md new file mode 100644 index 00000000000..704167c52a6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings` Documentation + +The `replicationprotectioncontainermappings` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings" +``` + + +### Client Initialization + +```go +client := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectionContainerMappingValue") + +payload := replicationprotectioncontainermappings.CreateProtectionContainerMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectionContainerMappingValue") + +payload := replicationprotectioncontainermappings.RemoveProtectionContainerMappingInput{ + // ... +} + + +if err := client.DeleteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectionContainerMappingValue") + +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: `ReplicationProtectionContainerMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Purge` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectionContainerMappingValue") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Update` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectionContainerMappingValue") + +payload := replicationprotectioncontainermappings.UpdateProtectionContainerMappingInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/client.go new file mode 100644 index 00000000000..ec466904755 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/client.go @@ -0,0 +1,26 @@ +package replicationprotectioncontainermappings + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionContainerMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionContainerMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionContainerMappingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationprotectioncontainermappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionContainerMappingsClient: %+v", err) + } + + return &ReplicationProtectionContainerMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/constants.go new file mode 100644 index 00000000000..59286568ec1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/constants.go @@ -0,0 +1,133 @@ +package replicationprotectioncontainermappings + +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 AgentAutoUpdateStatus string + +const ( + AgentAutoUpdateStatusDisabled AgentAutoUpdateStatus = "Disabled" + AgentAutoUpdateStatusEnabled AgentAutoUpdateStatus = "Enabled" +) + +func PossibleValuesForAgentAutoUpdateStatus() []string { + return []string{ + string(AgentAutoUpdateStatusDisabled), + string(AgentAutoUpdateStatusEnabled), + } +} + +func (s *AgentAutoUpdateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentAutoUpdateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentAutoUpdateStatus(input string) (*AgentAutoUpdateStatus, error) { + vals := map[string]AgentAutoUpdateStatus{ + "disabled": AgentAutoUpdateStatusDisabled, + "enabled": AgentAutoUpdateStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentAutoUpdateStatus(input) + return &out, nil +} + +type AutomationAccountAuthenticationType string + +const ( + AutomationAccountAuthenticationTypeRunAsAccount AutomationAccountAuthenticationType = "RunAsAccount" + AutomationAccountAuthenticationTypeSystemAssignedIdentity AutomationAccountAuthenticationType = "SystemAssignedIdentity" +) + +func PossibleValuesForAutomationAccountAuthenticationType() []string { + return []string{ + string(AutomationAccountAuthenticationTypeRunAsAccount), + string(AutomationAccountAuthenticationTypeSystemAssignedIdentity), + } +} + +func (s *AutomationAccountAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutomationAccountAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutomationAccountAuthenticationType(input string) (*AutomationAccountAuthenticationType, error) { + vals := map[string]AutomationAccountAuthenticationType{ + "runasaccount": AutomationAccountAuthenticationTypeRunAsAccount, + "systemassignedidentity": AutomationAccountAuthenticationTypeSystemAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutomationAccountAuthenticationType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..b295962cba5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go @@ -0,0 +1,143 @@ +package replicationprotectioncontainermappings + +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 = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..d52474eb84d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectioncontainermappings + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go new file mode 100644 index 00000000000..1d0d1550ea7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go @@ -0,0 +1,152 @@ +package replicationprotectioncontainermappings + +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 = &ReplicationProtectionContainerMappingId{} + +// ReplicationProtectionContainerMappingId is a struct representing the Resource ID for a Replication Protection Container Mapping +type ReplicationProtectionContainerMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionContainerMappingName string +} + +// NewReplicationProtectionContainerMappingID returns a new ReplicationProtectionContainerMappingId struct +func NewReplicationProtectionContainerMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionContainerMappingName string) ReplicationProtectionContainerMappingId { + return ReplicationProtectionContainerMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionContainerMappingName: replicationProtectionContainerMappingName, + } +} + +// ParseReplicationProtectionContainerMappingID parses 'input' into a ReplicationProtectionContainerMappingId +func ParseReplicationProtectionContainerMappingID(input string) (*ReplicationProtectionContainerMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerMappingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerMappingIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerMappingIDInsensitively(input string) (*ReplicationProtectionContainerMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerMappingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerMappingId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionContainerMappingName, ok = input.Parsed["replicationProtectionContainerMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerMappingName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerMappingID checks that 'input' can be parsed as a Replication Protection Container Mapping ID +func ValidateReplicationProtectionContainerMappingID(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 := ParseReplicationProtectionContainerMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionContainerMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionContainerMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationProtectionContainerMappings", "replicationProtectionContainerMappings", "replicationProtectionContainerMappings"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerMappingName", "replicationProtectionContainerMappingValue"), + } +} + +// String returns a human-readable description of this Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Container Mapping Name: %q", id.ReplicationProtectionContainerMappingName), + } + return fmt.Sprintf("Replication Protection Container Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go new file mode 100644 index 00000000000..d4a1211776c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go @@ -0,0 +1,417 @@ +package replicationprotectioncontainermappings + +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 = &ReplicationProtectionContainerMappingId{} + +func TestNewReplicationProtectionContainerMappingID(t *testing.T) { + id := NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectionContainerMappingValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationProtectionContainerMappingName != "replicationProtectionContainerMappingValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerMappingName'", id.ReplicationProtectionContainerMappingName, "replicationProtectionContainerMappingValue") + } +} + +func TestFormatReplicationProtectionContainerMappingID(t *testing.T) { + actual := NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectionContainerMappingValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectionContainerMappings/replicationProtectionContainerMappingValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerMappingId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectionContainerMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectionContainerMappings/replicationProtectionContainerMappingValue", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectionContainerMappingName: "replicationProtectionContainerMappingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectionContainerMappings/replicationProtectionContainerMappingValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerMappingID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionContainerMappingName != v.Expected.ReplicationProtectionContainerMappingName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerMappingName", v.Expected.ReplicationProtectionContainerMappingName, actual.ReplicationProtectionContainerMappingName) + } + + } +} + +func TestParseReplicationProtectionContainerMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerMappingId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectionContainerMappings", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectionContainerMappings/replicationProtectionContainerMappingValue", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectionContainerMappingName: "replicationProtectionContainerMappingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectionContainerMappings/replicationProtectionContainerMappingValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgVaLuE", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationProtectionContainerMappingName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerMappingIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionContainerMappingName != v.Expected.ReplicationProtectionContainerMappingName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerMappingName", v.Expected.ReplicationProtectionContainerMappingName, actual.ReplicationProtectionContainerMappingName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerMappingId(t *testing.T) { + segments := ReplicationProtectionContainerMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerMappingId 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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_vault.go new file mode 100644 index 00000000000..24f2f00d7b4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_vault.go @@ -0,0 +1,125 @@ +package replicationprotectioncontainermappings + +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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_vault_test.go new file mode 100644 index 00000000000..f61e45bac18 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectioncontainermappings + +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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_create.go new file mode 100644 index 00000000000..48f9d495b34 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_create.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainerMapping +} + +// Create ... +func (c ReplicationProtectionContainerMappingsClient) Create(ctx context.Context, id ReplicationProtectionContainerMappingId, input CreateProtectionContainerMappingInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input CreateProtectionContainerMappingInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_delete.go new file mode 100644 index 00000000000..a7da6f7e3e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_delete.go @@ -0,0 +1,74 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationProtectionContainerMappingsClient) Delete(ctx context.Context, id ReplicationProtectionContainerMappingId, input RemoveProtectionContainerMappingInput) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input RemoveProtectionContainerMappingInput) error { + result, err := c.Delete(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_get.go new file mode 100644 index 00000000000..ff1011f58ad --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_get.go @@ -0,0 +1,51 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainerMapping +} + +// Get ... +func (c ReplicationProtectionContainerMappingsClient) Get(ctx context.Context, id ReplicationProtectionContainerMappingId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_list.go new file mode 100644 index 00000000000..6d90e585c0f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_list.go @@ -0,0 +1,91 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainerMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainerMapping +} + +// List ... +func (c ReplicationProtectionContainerMappingsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationProtectionContainerMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectionContainerMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectionContainerMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ProtectionContainerMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainerMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate ProtectionContainerMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ProtectionContainerMapping, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..919f0608d73 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,91 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainerMapping +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainerMapping +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationProtectionContainerMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectionContainerMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, ProtectionContainerMappingOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, predicate ProtectionContainerMappingOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ProtectionContainerMapping, 0) + + resp, err := c.ListByReplicationProtectionContainers(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_purge.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_purge.go new file mode 100644 index 00000000000..fecbca3b41b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_purge.go @@ -0,0 +1,70 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationProtectionContainerMappingsClient) Purge(ctx context.Context, id ReplicationProtectionContainerMappingId) (result PurgeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) PurgeThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_update.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_update.go new file mode 100644 index 00000000000..6a2852dda40 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/method_update.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainerMapping +} + +// Update ... +func (c ReplicationProtectionContainerMappingsClient) Update(ctx context.Context, id ReplicationProtectionContainerMappingId, input UpdateProtectionContainerMappingInput) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) UpdateThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input UpdateProtectionContainerMappingInput) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go new file mode 100644 index 00000000000..f8472547d4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go @@ -0,0 +1,43 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerMappingInput = A2AContainerMappingInput{} + +type A2AContainerMappingInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + + // Fields inherited from ReplicationProviderSpecificContainerMappingInput +} + +var _ json.Marshaler = A2AContainerMappingInput{} + +func (s A2AContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper A2AContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AContainerMappingInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..7d5038331df --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go @@ -0,0 +1,45 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainerMappingProviderSpecificDetails = A2AProtectionContainerMappingDetails{} + +type A2AProtectionContainerMappingDetails struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + JobScheduleName *string `json:"jobScheduleName,omitempty"` + ScheduleName *string `json:"scheduleName,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails +} + +var _ json.Marshaler = A2AProtectionContainerMappingDetails{} + +func (s A2AProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AProtectionContainerMappingDetails: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go new file mode 100644 index 00000000000..e3734760574 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go @@ -0,0 +1,43 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificUpdateContainerMappingInput = A2AUpdateContainerMappingInput{} + +type A2AUpdateContainerMappingInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + + // Fields inherited from ReplicationProviderSpecificUpdateContainerMappingInput +} + +var _ json.Marshaler = A2AUpdateContainerMappingInput{} + +func (s A2AUpdateContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUpdateContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUpdateContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUpdateContainerMappingInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUpdateContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go new file mode 100644 index 00000000000..49e1a32d873 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionContainerMappingInput struct { + Properties *CreateProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..9c1938b0fed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go @@ -0,0 +1,42 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/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 CreateProtectionContainerMappingInputProperties struct { + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificInput ReplicationProviderSpecificContainerMappingInput `json:"providerSpecificInput"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` +} + +var _ json.Unmarshaler = &CreateProtectionContainerMappingInputProperties{} + +func (s *CreateProtectionContainerMappingInputProperties) UnmarshalJSON(bytes []byte) error { + type alias CreateProtectionContainerMappingInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into CreateProtectionContainerMappingInputProperties: %+v", err) + } + + s.PolicyId = decoded.PolicyId + s.TargetProtectionContainerId = decoded.TargetProtectionContainerId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionContainerMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := unmarshalReplicationProviderSpecificContainerMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'CreateProtectionContainerMappingInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_healtherror.go new file mode 100644 index 00000000000..a4c7339daba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotectioncontainermappings + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..37be76a4162 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go @@ -0,0 +1,41 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainerMappingProviderSpecificDetails = InMageRcmProtectionContainerMappingDetails{} + +type InMageRcmProtectionContainerMappingDetails struct { + EnableAgentAutoUpgrade *string `json:"enableAgentAutoUpgrade,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails +} + +var _ json.Marshaler = InMageRcmProtectionContainerMappingDetails{} + +func (s InMageRcmProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go new file mode 100644 index 00000000000..1ae5b455516 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go @@ -0,0 +1,41 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificUpdateContainerMappingInput = InMageRcmUpdateContainerMappingInput{} + +type InMageRcmUpdateContainerMappingInput struct { + EnableAgentAutoUpgrade string `json:"enableAgentAutoUpgrade"` + + // Fields inherited from ReplicationProviderSpecificUpdateContainerMappingInput +} + +var _ json.Marshaler = InMageRcmUpdateContainerMappingInput{} + +func (s InMageRcmUpdateContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_innerhealtherror.go new file mode 100644 index 00000000000..20d411ae371 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotectioncontainermappings + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go new file mode 100644 index 00000000000..6fcec0153e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go @@ -0,0 +1,12 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectionContainerMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go new file mode 100644 index 00000000000..2cf9d980640 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go @@ -0,0 +1,58 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/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 ProtectionContainerMappingProperties struct { + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificDetails ProtectionContainerMappingProviderSpecificDetails `json:"providerSpecificDetails"` + SourceFabricFriendlyName *string `json:"sourceFabricFriendlyName,omitempty"` + SourceProtectionContainerFriendlyName *string `json:"sourceProtectionContainerFriendlyName,omitempty"` + State *string `json:"state,omitempty"` + TargetFabricFriendlyName *string `json:"targetFabricFriendlyName,omitempty"` + TargetProtectionContainerFriendlyName *string `json:"targetProtectionContainerFriendlyName,omitempty"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionContainerMappingProperties{} + +func (s *ProtectionContainerMappingProperties) UnmarshalJSON(bytes []byte) error { + type alias ProtectionContainerMappingProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionContainerMappingProperties: %+v", err) + } + + s.Health = decoded.Health + s.HealthErrorDetails = decoded.HealthErrorDetails + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.SourceFabricFriendlyName = decoded.SourceFabricFriendlyName + s.SourceProtectionContainerFriendlyName = decoded.SourceProtectionContainerFriendlyName + s.State = decoded.State + s.TargetFabricFriendlyName = decoded.TargetFabricFriendlyName + s.TargetProtectionContainerFriendlyName = decoded.TargetProtectionContainerFriendlyName + s.TargetProtectionContainerId = decoded.TargetProtectionContainerId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerMappingProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalProtectionContainerMappingProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ProtectionContainerMappingProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go new file mode 100644 index 00000000000..265a84762fb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go @@ -0,0 +1,69 @@ +package replicationprotectioncontainermappings + +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 ProtectionContainerMappingProviderSpecificDetails interface { +} + +// RawProtectionContainerMappingProviderSpecificDetailsImpl 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 RawProtectionContainerMappingProviderSpecificDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionContainerMappingProviderSpecificDetailsImplementation(input []byte) (ProtectionContainerMappingProviderSpecificDetails, 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 ProtectionContainerMappingProviderSpecificDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + out := RawProtectionContainerMappingProviderSpecificDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go new file mode 100644 index 00000000000..ac6d64ca0d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveProtectionContainerMappingInput struct { + Properties *RemoveProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..cda0927d8cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveProtectionContainerMappingInputProperties struct { + ProviderSpecificInput *ReplicationProviderContainerUnmappingInput `json:"providerSpecificInput,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go new file mode 100644 index 00000000000..862047c52a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProviderContainerUnmappingInput struct { + InstanceType *string `json:"instanceType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go new file mode 100644 index 00000000000..baeb2a5e095 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go @@ -0,0 +1,61 @@ +package replicationprotectioncontainermappings + +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 ReplicationProviderSpecificContainerMappingInput interface { +} + +// RawReplicationProviderSpecificContainerMappingInputImpl 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 RawReplicationProviderSpecificContainerMappingInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalReplicationProviderSpecificContainerMappingInputImplementation(input []byte) (ReplicationProviderSpecificContainerMappingInput, 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 ReplicationProviderSpecificContainerMappingInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AContainerMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtContainerMappingInput: %+v", err) + } + return out, nil + } + + out := RawReplicationProviderSpecificContainerMappingInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go new file mode 100644 index 00000000000..462294f3689 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go @@ -0,0 +1,61 @@ +package replicationprotectioncontainermappings + +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 ReplicationProviderSpecificUpdateContainerMappingInput interface { +} + +// RawReplicationProviderSpecificUpdateContainerMappingInputImpl 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 RawReplicationProviderSpecificUpdateContainerMappingInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalReplicationProviderSpecificUpdateContainerMappingInputImplementation(input []byte) (ReplicationProviderSpecificUpdateContainerMappingInput, 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 ReplicationProviderSpecificUpdateContainerMappingInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AUpdateContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUpdateContainerMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateContainerMappingInput: %+v", err) + } + return out, nil + } + + out := RawReplicationProviderSpecificUpdateContainerMappingInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go new file mode 100644 index 00000000000..9c2d7bf172c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateProtectionContainerMappingInput struct { + Properties *UpdateProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..e021c62ed1f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go @@ -0,0 +1,32 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/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 UpdateProtectionContainerMappingInputProperties struct { + ProviderSpecificInput ReplicationProviderSpecificUpdateContainerMappingInput `json:"providerSpecificInput"` +} + +var _ json.Unmarshaler = &UpdateProtectionContainerMappingInputProperties{} + +func (s *UpdateProtectionContainerMappingInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateProtectionContainerMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := unmarshalReplicationProviderSpecificUpdateContainerMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'UpdateProtectionContainerMappingInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go new file mode 100644 index 00000000000..d4711386360 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go @@ -0,0 +1,46 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerMappingInput = VMwareCbtContainerMappingInput{} + +type VMwareCbtContainerMappingInput struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + ServiceBusConnectionStringSecretName *string `json:"serviceBusConnectionStringSecretName,omitempty"` + StorageAccountId string `json:"storageAccountId"` + StorageAccountSasSecretName *string `json:"storageAccountSasSecretName,omitempty"` + TargetLocation string `json:"targetLocation"` + + // Fields inherited from ReplicationProviderSpecificContainerMappingInput +} + +var _ json.Marshaler = VMwareCbtContainerMappingInput{} + +func (s VMwareCbtContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtContainerMappingInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..29bd438cf42 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go @@ -0,0 +1,48 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainerMappingProviderSpecificDetails = VMwareCbtProtectionContainerMappingDetails{} + +type VMwareCbtProtectionContainerMappingDetails struct { + ExcludedSkus *[]string `json:"excludedSkus,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + RoleSizeToNicCountMap *map[string]int64 `json:"roleSizeToNicCountMap,omitempty"` + ServiceBusConnectionStringSecretName *string `json:"serviceBusConnectionStringSecretName,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + StorageAccountSasSecretName *string `json:"storageAccountSasSecretName,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails +} + +var _ json.Marshaler = VMwareCbtProtectionContainerMappingDetails{} + +func (s VMwareCbtProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/predicates.go new file mode 100644 index 00000000000..c60ddcb4a31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerMappingOperationPredicate) Matches(input ProtectionContainerMapping) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/version.go new file mode 100644 index 00000000000..b4f8f45504d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainermappings/version.go @@ -0,0 +1,12 @@ +package replicationprotectioncontainermappings + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationprotectioncontainermappings/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/README.md new file mode 100644 index 00000000000..803354ac411 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers` Documentation + +The `replicationprotectioncontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers" +``` + + +### Client Initialization + +```go +client := replicationprotectioncontainers.NewReplicationProtectionContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +payload := replicationprotectioncontainers.CreateProtectionContainerInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.DiscoverProtectableItem` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +payload := replicationprotectioncontainers.DiscoverProtectableItemRequest{ + // ... +} + + +if err := client.DiscoverProtectableItemThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +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: `ReplicationProtectionContainersClient.List` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.SwitchProtection` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + +payload := replicationprotectioncontainers.SwitchProtectionInput{ + // ... +} + + +if err := client.SwitchProtectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/client.go new file mode 100644 index 00000000000..42e87f35110 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/client.go @@ -0,0 +1,26 @@ +package replicationprotectioncontainers + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionContainersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionContainersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionContainersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationprotectioncontainers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionContainersClient: %+v", err) + } + + return &ReplicationProtectionContainersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationfabric.go new file mode 100644 index 00000000000..ad092deacfd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationfabric.go @@ -0,0 +1,134 @@ +package replicationprotectioncontainers + +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 = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationfabric_test.go new file mode 100644 index 00000000000..1355a4496c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationprotectioncontainers + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..aa09783d564 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go @@ -0,0 +1,143 @@ +package replicationprotectioncontainers + +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 = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..2e1bcb68410 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectioncontainers + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_vault.go new file mode 100644 index 00000000000..c7b14dde76e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_vault.go @@ -0,0 +1,125 @@ +package replicationprotectioncontainers + +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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_vault_test.go new file mode 100644 index 00000000000..a1b4d6d92bf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectioncontainers + +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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_create.go new file mode 100644 index 00000000000..ceb6aa4ab31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_create.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// Create ... +func (c ReplicationProtectionContainersClient) Create(ctx context.Context, id ReplicationProtectionContainerId, input CreateProtectionContainerInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectionContainersClient) CreateThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input CreateProtectionContainerInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_delete.go new file mode 100644 index 00000000000..63ac30675e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_delete.go @@ -0,0 +1,70 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationProtectionContainersClient) Delete(ctx context.Context, id ReplicationProtectionContainerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationProtectionContainersClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectionContainerId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_discoverprotectableitem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_discoverprotectableitem.go new file mode 100644 index 00000000000..6a65eda5d16 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_discoverprotectableitem.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverProtectableItemOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// DiscoverProtectableItem ... +func (c ReplicationProtectionContainersClient) DiscoverProtectableItem(ctx context.Context, id ReplicationProtectionContainerId, input DiscoverProtectableItemRequest) (result DiscoverProtectableItemOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverProtectableItem", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DiscoverProtectableItemThenPoll performs DiscoverProtectableItem then polls until it's completed +func (c ReplicationProtectionContainersClient) DiscoverProtectableItemThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input DiscoverProtectableItemRequest) error { + result, err := c.DiscoverProtectableItem(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DiscoverProtectableItem: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DiscoverProtectableItem: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_get.go new file mode 100644 index 00000000000..47b00a8c33d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_get.go @@ -0,0 +1,51 @@ +package replicationprotectioncontainers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// Get ... +func (c ReplicationProtectionContainersClient) Get(ctx context.Context, id ReplicationProtectionContainerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_list.go new file mode 100644 index 00000000000..d511455689d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_list.go @@ -0,0 +1,91 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainer +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainer +} + +// List ... +func (c ReplicationProtectionContainersClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationProtectionContainers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectionContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectionContainersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ProtectionContainerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate ProtectionContainerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ProtectionContainer, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..c4c9cc9b50c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go @@ -0,0 +1,91 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainer +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainer +} + +// ListByReplicationFabrics ... +func (c ReplicationProtectionContainersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationProtectionContainers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectionContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationProtectionContainersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, ProtectionContainerOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate ProtectionContainerOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]ProtectionContainer, 0) + + resp, err := c.ListByReplicationFabrics(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_switchprotection.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_switchprotection.go new file mode 100644 index 00000000000..a9b935c76c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/method_switchprotection.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProtectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// SwitchProtection ... +func (c ReplicationProtectionContainersClient) SwitchProtection(ctx context.Context, id ReplicationProtectionContainerId, input SwitchProtectionInput) (result SwitchProtectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchprotection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SwitchProtectionThenPoll performs SwitchProtection then polls until it's completed +func (c ReplicationProtectionContainersClient) SwitchProtectionThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input SwitchProtectionInput) error { + result, err := c.SwitchProtection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwitchProtection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwitchProtection: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2acontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2acontainercreationinput.go new file mode 100644 index 00000000000..266ed59b59f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2acontainercreationinput.go @@ -0,0 +1,40 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerCreationInput = A2AContainerCreationInput{} + +type A2AContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput +} + +var _ json.Marshaler = A2AContainerCreationInput{} + +func (s A2AContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2AContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AContainerCreationInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go new file mode 100644 index 00000000000..d5d6094ea4e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go @@ -0,0 +1,40 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerCreationInput = A2ACrossClusterMigrationContainerCreationInput{} + +type A2ACrossClusterMigrationContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput +} + +var _ json.Marshaler = A2ACrossClusterMigrationContainerCreationInput{} + +func (s A2ACrossClusterMigrationContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go new file mode 100644 index 00000000000..a2d5ecbeefb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go @@ -0,0 +1,53 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SwitchProtectionProviderSpecificInput = A2ASwitchProtectionInput{} + +type A2ASwitchProtectionInput struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from SwitchProtectionProviderSpecificInput +} + +var _ json.Marshaler = A2ASwitchProtectionInput{} + +func (s A2ASwitchProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2ASwitchProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ASwitchProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ASwitchProtectionInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ASwitchProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go new file mode 100644 index 00000000000..1e0784c90fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryAzureStorageAccountId string `json:"recoveryAzureStorageAccountId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go new file mode 100644 index 00000000000..6c0c988393d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go @@ -0,0 +1,14 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go new file mode 100644 index 00000000000..55175403c81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionContainerInput struct { + Properties *CreateProtectionContainerInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go new file mode 100644 index 00000000000..c3322f96a09 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go @@ -0,0 +1,41 @@ +package replicationprotectioncontainers + +import ( + "encoding/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 CreateProtectionContainerInputProperties struct { + ProviderSpecificInput *[]ReplicationProviderSpecificContainerCreationInput `json:"providerSpecificInput,omitempty"` +} + +var _ json.Unmarshaler = &CreateProtectionContainerInputProperties{} + +func (s *CreateProtectionContainerInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionContainerInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificInput into list []json.RawMessage: %+v", err) + } + + output := make([]ReplicationProviderSpecificContainerCreationInput, 0) + for i, val := range listTemp { + impl, err := unmarshalReplicationProviderSpecificContainerCreationInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificInput' for 'CreateProtectionContainerInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificInput = &output + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go new file mode 100644 index 00000000000..ceca9005e59 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverProtectableItemRequest struct { + Properties *DiscoverProtectableItemRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go new file mode 100644 index 00000000000..fee5502a3c7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverProtectableItemRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + OsType *string `json:"osType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_diskencryptioninfo.go new file mode 100644 index 00000000000..997e7018bf6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..e67e3239790 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..e5eb025e741 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..0236469ade2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainer.go @@ -0,0 +1,12 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainer struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectionContainerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go new file mode 100644 index 00000000000..ccda06f411a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerFabricSpecificDetails struct { + InstanceType *string `json:"instanceType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainerproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainerproperties.go new file mode 100644 index 00000000000..baa48fb4dcd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_protectioncontainerproperties.go @@ -0,0 +1,14 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerProperties struct { + FabricFriendlyName *string `json:"fabricFriendlyName,omitempty"` + FabricSpecificDetails *ProtectionContainerFabricSpecificDetails `json:"fabricSpecificDetails,omitempty"` + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PairingStatus *string `json:"pairingStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + Role *string `json:"role,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go new file mode 100644 index 00000000000..a7fde08841d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go @@ -0,0 +1,69 @@ +package replicationprotectioncontainers + +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 ReplicationProviderSpecificContainerCreationInput interface { +} + +// RawReplicationProviderSpecificContainerCreationInputImpl 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 RawReplicationProviderSpecificContainerCreationInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalReplicationProviderSpecificContainerCreationInputImplementation(input []byte) (ReplicationProviderSpecificContainerCreationInput, 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 ReplicationProviderSpecificContainerCreationInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AContainerCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtContainerCreationInput: %+v", err) + } + return out, nil + } + + out := RawReplicationProviderSpecificContainerCreationInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectioninput.go new file mode 100644 index 00000000000..ebb469d6c10 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProtectionInput struct { + Properties *SwitchProtectionInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go new file mode 100644 index 00000000000..9ddc61f5e27 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go @@ -0,0 +1,40 @@ +package replicationprotectioncontainers + +import ( + "encoding/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 SwitchProtectionInputProperties struct { + ProviderSpecificDetails SwitchProtectionProviderSpecificInput `json:"providerSpecificDetails"` + ReplicationProtectedItemName *string `json:"replicationProtectedItemName,omitempty"` +} + +var _ json.Unmarshaler = &SwitchProtectionInputProperties{} + +func (s *SwitchProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + type alias SwitchProtectionInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into SwitchProtectionInputProperties: %+v", err) + } + + s.ReplicationProtectedItemName = decoded.ReplicationProtectedItemName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SwitchProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalSwitchProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'SwitchProtectionInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go new file mode 100644 index 00000000000..5d72ac382a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationprotectioncontainers + +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 SwitchProtectionProviderSpecificInput interface { +} + +// RawSwitchProtectionProviderSpecificInputImpl 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 RawSwitchProtectionProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalSwitchProtectionProviderSpecificInputImplementation(input []byte) (SwitchProtectionProviderSpecificInput, 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 SwitchProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2ASwitchProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ASwitchProtectionInput: %+v", err) + } + return out, nil + } + + out := RawSwitchProtectionProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go new file mode 100644 index 00000000000..2db1f2ac651 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go @@ -0,0 +1,40 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerCreationInput = VMwareCbtContainerCreationInput{} + +type VMwareCbtContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput +} + +var _ json.Marshaler = VMwareCbtContainerCreationInput{} + +func (s VMwareCbtContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtContainerCreationInput: %+v", err) + } + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/predicates.go new file mode 100644 index 00000000000..842a1e7ff08 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerOperationPredicate) Matches(input ProtectionContainer) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/version.go new file mode 100644 index 00000000000..7a12a62ad80 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectioncontainers/version.go @@ -0,0 +1,12 @@ +package replicationprotectioncontainers + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationprotectioncontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/README.md new file mode 100644 index 00000000000..2c2f72c386b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents` Documentation + +The `replicationprotectionintents` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents" +``` + + +### Client Initialization + +```go +client := replicationprotectionintents.NewReplicationProtectionIntentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionIntentsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationProtectionIntentValue") + +payload := replicationprotectionintents.CreateProtectionIntentInput{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReplicationProtectionIntentsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationProtectionIntentValue") + +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: `ReplicationProtectionIntentsClient.List` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, replicationprotectionintents.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationprotectionintents.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/client.go new file mode 100644 index 00000000000..c2c414081be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/client.go @@ -0,0 +1,26 @@ +package replicationprotectionintents + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionIntentsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionIntentsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionIntentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationprotectionintents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionIntentsClient: %+v", err) + } + + return &ReplicationProtectionIntentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/constants.go new file mode 100644 index 00000000000..359018e5915 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/constants.go @@ -0,0 +1,218 @@ +package replicationprotectionintents + +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 A2ARecoveryAvailabilityType string + +const ( + A2ARecoveryAvailabilityTypeAvailabilitySet A2ARecoveryAvailabilityType = "AvailabilitySet" + A2ARecoveryAvailabilityTypeAvailabilityZone A2ARecoveryAvailabilityType = "AvailabilityZone" + A2ARecoveryAvailabilityTypeSingle A2ARecoveryAvailabilityType = "Single" +) + +func PossibleValuesForA2ARecoveryAvailabilityType() []string { + return []string{ + string(A2ARecoveryAvailabilityTypeAvailabilitySet), + string(A2ARecoveryAvailabilityTypeAvailabilityZone), + string(A2ARecoveryAvailabilityTypeSingle), + } +} + +func (s *A2ARecoveryAvailabilityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseA2ARecoveryAvailabilityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseA2ARecoveryAvailabilityType(input string) (*A2ARecoveryAvailabilityType, error) { + vals := map[string]A2ARecoveryAvailabilityType{ + "availabilityset": A2ARecoveryAvailabilityTypeAvailabilitySet, + "availabilityzone": A2ARecoveryAvailabilityTypeAvailabilityZone, + "single": A2ARecoveryAvailabilityTypeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := A2ARecoveryAvailabilityType(input) + return &out, nil +} + +type AgentAutoUpdateStatus string + +const ( + AgentAutoUpdateStatusDisabled AgentAutoUpdateStatus = "Disabled" + AgentAutoUpdateStatusEnabled AgentAutoUpdateStatus = "Enabled" +) + +func PossibleValuesForAgentAutoUpdateStatus() []string { + return []string{ + string(AgentAutoUpdateStatusDisabled), + string(AgentAutoUpdateStatusEnabled), + } +} + +func (s *AgentAutoUpdateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentAutoUpdateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentAutoUpdateStatus(input string) (*AgentAutoUpdateStatus, error) { + vals := map[string]AgentAutoUpdateStatus{ + "disabled": AgentAutoUpdateStatusDisabled, + "enabled": AgentAutoUpdateStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentAutoUpdateStatus(input) + return &out, nil +} + +type AutoProtectionOfDataDisk string + +const ( + AutoProtectionOfDataDiskDisabled AutoProtectionOfDataDisk = "Disabled" + AutoProtectionOfDataDiskEnabled AutoProtectionOfDataDisk = "Enabled" +) + +func PossibleValuesForAutoProtectionOfDataDisk() []string { + return []string{ + string(AutoProtectionOfDataDiskDisabled), + string(AutoProtectionOfDataDiskEnabled), + } +} + +func (s *AutoProtectionOfDataDisk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoProtectionOfDataDisk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoProtectionOfDataDisk(input string) (*AutoProtectionOfDataDisk, error) { + vals := map[string]AutoProtectionOfDataDisk{ + "disabled": AutoProtectionOfDataDiskDisabled, + "enabled": AutoProtectionOfDataDiskEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoProtectionOfDataDisk(input) + return &out, nil +} + +type AutomationAccountAuthenticationType string + +const ( + AutomationAccountAuthenticationTypeRunAsAccount AutomationAccountAuthenticationType = "RunAsAccount" + AutomationAccountAuthenticationTypeSystemAssignedIdentity AutomationAccountAuthenticationType = "SystemAssignedIdentity" +) + +func PossibleValuesForAutomationAccountAuthenticationType() []string { + return []string{ + string(AutomationAccountAuthenticationTypeRunAsAccount), + string(AutomationAccountAuthenticationTypeSystemAssignedIdentity), + } +} + +func (s *AutomationAccountAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutomationAccountAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutomationAccountAuthenticationType(input string) (*AutomationAccountAuthenticationType, error) { + vals := map[string]AutomationAccountAuthenticationType{ + "runasaccount": AutomationAccountAuthenticationTypeRunAsAccount, + "systemassignedidentity": AutomationAccountAuthenticationTypeSystemAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutomationAccountAuthenticationType(input) + return &out, nil +} + +type SetMultiVMSyncStatus string + +const ( + SetMultiVMSyncStatusDisable SetMultiVMSyncStatus = "Disable" + SetMultiVMSyncStatusEnable SetMultiVMSyncStatus = "Enable" +) + +func PossibleValuesForSetMultiVMSyncStatus() []string { + return []string{ + string(SetMultiVMSyncStatusDisable), + string(SetMultiVMSyncStatusEnable), + } +} + +func (s *SetMultiVMSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSetMultiVMSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSetMultiVMSyncStatus(input string) (*SetMultiVMSyncStatus, error) { + vals := map[string]SetMultiVMSyncStatus{ + "disable": SetMultiVMSyncStatusDisable, + "enable": SetMultiVMSyncStatusEnable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SetMultiVMSyncStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_replicationprotectionintent.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_replicationprotectionintent.go new file mode 100644 index 00000000000..4c6efd178de --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_replicationprotectionintent.go @@ -0,0 +1,134 @@ +package replicationprotectionintents + +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 = &ReplicationProtectionIntentId{} + +// ReplicationProtectionIntentId is a struct representing the Resource ID for a Replication Protection Intent +type ReplicationProtectionIntentId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationProtectionIntentName string +} + +// NewReplicationProtectionIntentID returns a new ReplicationProtectionIntentId struct +func NewReplicationProtectionIntentID(subscriptionId string, resourceGroupName string, vaultName string, replicationProtectionIntentName string) ReplicationProtectionIntentId { + return ReplicationProtectionIntentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationProtectionIntentName: replicationProtectionIntentName, + } +} + +// ParseReplicationProtectionIntentID parses 'input' into a ReplicationProtectionIntentId +func ParseReplicationProtectionIntentID(input string) (*ReplicationProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionIntentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionIntentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionIntentIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionIntentId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionIntentIDInsensitively(input string) (*ReplicationProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionIntentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionIntentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionIntentId) 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.ReplicationProtectionIntentName, ok = input.Parsed["replicationProtectionIntentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionIntentName", input) + } + + return nil +} + +// ValidateReplicationProtectionIntentID checks that 'input' can be parsed as a Replication Protection Intent ID +func ValidateReplicationProtectionIntentID(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 := ParseReplicationProtectionIntentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Intent ID +func (id ReplicationProtectionIntentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationProtectionIntents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationProtectionIntentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Intent ID +func (id ReplicationProtectionIntentId) 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("staticReplicationProtectionIntents", "replicationProtectionIntents", "replicationProtectionIntents"), + resourceids.UserSpecifiedSegment("replicationProtectionIntentName", "replicationProtectionIntentValue"), + } +} + +// String returns a human-readable description of this Replication Protection Intent ID +func (id ReplicationProtectionIntentId) 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("Replication Protection Intent Name: %q", id.ReplicationProtectionIntentName), + } + return fmt.Sprintf("Replication Protection Intent (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_replicationprotectionintent_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_replicationprotectionintent_test.go new file mode 100644 index 00000000000..0f27eefeb93 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_replicationprotectionintent_test.go @@ -0,0 +1,327 @@ +package replicationprotectionintents + +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 = &ReplicationProtectionIntentId{} + +func TestNewReplicationProtectionIntentID(t *testing.T) { + id := NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationProtectionIntentValue") + + 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.ReplicationProtectionIntentName != "replicationProtectionIntentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionIntentName'", id.ReplicationProtectionIntentName, "replicationProtectionIntentValue") + } +} + +func TestFormatReplicationProtectionIntentID(t *testing.T) { + actual := NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationProtectionIntentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationProtectionIntents/replicationProtectionIntentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionIntentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionIntentId + }{ + { + // 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/replicationProtectionIntents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationProtectionIntents/replicationProtectionIntentValue", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationProtectionIntentName: "replicationProtectionIntentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationProtectionIntents/replicationProtectionIntentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionIntentID(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.ReplicationProtectionIntentName != v.Expected.ReplicationProtectionIntentName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionIntentName", v.Expected.ReplicationProtectionIntentName, actual.ReplicationProtectionIntentName) + } + + } +} + +func TestParseReplicationProtectionIntentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionIntentId + }{ + { + // 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/replicationProtectionIntents", + Error: 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/rEpLiCaTiOnPrOtEcTiOnInTeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationProtectionIntents/replicationProtectionIntentValue", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationProtectionIntentName: "replicationProtectionIntentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationProtectionIntents/replicationProtectionIntentValue/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/rEpLiCaTiOnPrOtEcTiOnInTeNtS/rEpLiCaTiOnPrOtEcTiOnInTeNtVaLuE", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationProtectionIntentName: "rEpLiCaTiOnPrOtEcTiOnInTeNtVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnPrOtEcTiOnInTeNtS/rEpLiCaTiOnPrOtEcTiOnInTeNtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionIntentIDInsensitively(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.ReplicationProtectionIntentName != v.Expected.ReplicationProtectionIntentName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionIntentName", v.Expected.ReplicationProtectionIntentName, actual.ReplicationProtectionIntentName) + } + + } +} + +func TestSegmentsForReplicationProtectionIntentId(t *testing.T) { + segments := ReplicationProtectionIntentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionIntentId 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/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_vault.go new file mode 100644 index 00000000000..26bfcfd8c9f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_vault.go @@ -0,0 +1,125 @@ +package replicationprotectionintents + +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/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_vault_test.go new file mode 100644 index 00000000000..d36ec8102e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectionintents + +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/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_create.go new file mode 100644 index 00000000000..0552f740e30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_create.go @@ -0,0 +1,55 @@ +package replicationprotectionintents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionIntent +} + +// Create ... +func (c ReplicationProtectionIntentsClient) Create(ctx context.Context, id ReplicationProtectionIntentId, input CreateProtectionIntentInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_get.go new file mode 100644 index 00000000000..a8aaf682509 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_get.go @@ -0,0 +1,51 @@ +package replicationprotectionintents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionIntent +} + +// Get ... +func (c ReplicationProtectionIntentsClient) Get(ctx context.Context, id ReplicationProtectionIntentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_list.go new file mode 100644 index 00000000000..e8744178eef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/method_list.go @@ -0,0 +1,123 @@ +package replicationprotectionintents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectionIntent +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectionIntent +} + +type ListOperationOptions struct { + SkipToken *string + TakeToken *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + return &out +} + +// List ... +func (c ReplicationProtectionIntentsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationProtectionIntents", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationProtectionIntent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectionIntentsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationProtectionIntentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionIntentsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationProtectionIntentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationProtectionIntent, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go new file mode 100644 index 00000000000..d559110e101 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go @@ -0,0 +1,143 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CreateProtectionIntentProviderSpecificDetails = A2ACreateProtectionIntentInput{} + +type A2ACreateProtectionIntentInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId string `json:"fabricObjectId"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation string `json:"primaryLocation"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + ProtectionProfileCustomInput ProtectionProfileCustomDetails `json:"protectionProfileCustomInput"` + RecoveryAvailabilitySetCustomInput RecoveryAvailabilitySetCustomDetails `json:"recoveryAvailabilitySetCustomInput"` + RecoveryAvailabilityType A2ARecoveryAvailabilityType `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccount StorageAccountCustomDetails `json:"recoveryBootDiagStorageAccount"` + RecoveryLocation string `json:"recoveryLocation"` + RecoveryProximityPlacementGroupCustomInput RecoveryProximityPlacementGroupCustomDetails `json:"recoveryProximityPlacementGroupCustomInput"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoverySubscriptionId string `json:"recoverySubscriptionId"` + RecoveryVirtualNetworkCustomInput RecoveryVirtualNetworkCustomDetails `json:"recoveryVirtualNetworkCustomInput"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from CreateProtectionIntentProviderSpecificDetails +} + +var _ json.Marshaler = A2ACreateProtectionIntentInput{} + +func (s A2ACreateProtectionIntentInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACreateProtectionIntentInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACreateProtectionIntentInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACreateProtectionIntentInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACreateProtectionIntentInput: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &A2ACreateProtectionIntentInput{} + +func (s *A2ACreateProtectionIntentInput) UnmarshalJSON(bytes []byte) error { + type alias A2ACreateProtectionIntentInput + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into A2ACreateProtectionIntentInput: %+v", err) + } + + s.AgentAutoUpdateStatus = decoded.AgentAutoUpdateStatus + s.AutoProtectionOfDataDisk = decoded.AutoProtectionOfDataDisk + s.AutomationAccountArmId = decoded.AutomationAccountArmId + s.AutomationAccountAuthenticationType = decoded.AutomationAccountAuthenticationType + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.FabricObjectId = decoded.FabricObjectId + s.MultiVMGroupId = decoded.MultiVMGroupId + s.MultiVMGroupName = decoded.MultiVMGroupName + s.PrimaryLocation = decoded.PrimaryLocation + s.RecoveryAvailabilityType = decoded.RecoveryAvailabilityType + s.RecoveryAvailabilityZone = decoded.RecoveryAvailabilityZone + s.RecoveryLocation = decoded.RecoveryLocation + s.RecoveryResourceGroupId = decoded.RecoveryResourceGroupId + s.RecoverySubscriptionId = decoded.RecoverySubscriptionId + s.VMDisks = decoded.VMDisks + s.VMManagedDisks = decoded.VMManagedDisks + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2ACreateProtectionIntentInput into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := unmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["protectionProfileCustomInput"]; ok { + impl, err := unmarshalProtectionProfileCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProtectionProfileCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.ProtectionProfileCustomInput = impl + } + + if v, ok := temp["recoveryAvailabilitySetCustomInput"]; ok { + impl, err := unmarshalRecoveryAvailabilitySetCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAvailabilitySetCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryAvailabilitySetCustomInput = impl + } + + if v, ok := temp["recoveryBootDiagStorageAccount"]; ok { + impl, err := unmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryBootDiagStorageAccount' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryBootDiagStorageAccount = impl + } + + if v, ok := temp["recoveryProximityPlacementGroupCustomInput"]; ok { + impl, err := unmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryProximityPlacementGroupCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryProximityPlacementGroupCustomInput = impl + } + + if v, ok := temp["recoveryVirtualNetworkCustomInput"]; ok { + impl, err := unmarshalRecoveryVirtualNetworkCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryVirtualNetworkCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryVirtualNetworkCustomInput = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go new file mode 100644 index 00000000000..3e73bb8e6f8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go @@ -0,0 +1,49 @@ +package replicationprotectionintents + +import ( + "encoding/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 A2AProtectionIntentDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + RecoveryAzureStorageAccountCustomInput StorageAccountCustomDetails `json:"recoveryAzureStorageAccountCustomInput"` +} + +var _ json.Unmarshaler = &A2AProtectionIntentDiskInputDetails{} + +func (s *A2AProtectionIntentDiskInputDetails) UnmarshalJSON(bytes []byte) error { + type alias A2AProtectionIntentDiskInputDetails + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into A2AProtectionIntentDiskInputDetails: %+v", err) + } + + s.DiskUri = decoded.DiskUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AProtectionIntentDiskInputDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := unmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2AProtectionIntentDiskInputDetails': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["recoveryAzureStorageAccountCustomInput"]; ok { + impl, err := unmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAzureStorageAccountCustomInput' for 'A2AProtectionIntentDiskInputDetails': %+v", err) + } + s.RecoveryAzureStorageAccountCustomInput = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go new file mode 100644 index 00000000000..fdc740a14fb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go @@ -0,0 +1,57 @@ +package replicationprotectionintents + +import ( + "encoding/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 A2AProtectionIntentManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupCustomInput RecoveryResourceGroupCustomDetails `json:"recoveryResourceGroupCustomInput"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} + +var _ json.Unmarshaler = &A2AProtectionIntentManagedDiskInputDetails{} + +func (s *A2AProtectionIntentManagedDiskInputDetails) UnmarshalJSON(bytes []byte) error { + type alias A2AProtectionIntentManagedDiskInputDetails + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into A2AProtectionIntentManagedDiskInputDetails: %+v", err) + } + + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.DiskId = decoded.DiskId + s.RecoveryDiskEncryptionSetId = decoded.RecoveryDiskEncryptionSetId + s.RecoveryReplicaDiskAccountType = decoded.RecoveryReplicaDiskAccountType + s.RecoveryTargetDiskAccountType = decoded.RecoveryTargetDiskAccountType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AProtectionIntentManagedDiskInputDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := unmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2AProtectionIntentManagedDiskInputDetails': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["recoveryResourceGroupCustomInput"]; ok { + impl, err := unmarshalRecoveryResourceGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryResourceGroupCustomInput' for 'A2AProtectionIntentManagedDiskInputDetails': %+v", err) + } + s.RecoveryResourceGroupCustomInput = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2areplicationintentdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2areplicationintentdetails.go new file mode 100644 index 00000000000..9605642ee8d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_a2areplicationintentdetails.go @@ -0,0 +1,143 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProtectionIntentProviderSpecificSettings = A2AReplicationIntentDetails{} + +type A2AReplicationIntentDetails struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation *string `json:"primaryLocation,omitempty"` + PrimaryStagingStorageAccount StorageAccountCustomDetails `json:"primaryStagingStorageAccount"` + ProtectionProfile ProtectionProfileCustomDetails `json:"protectionProfile"` + RecoveryAvailabilitySet RecoveryAvailabilitySetCustomDetails `json:"recoveryAvailabilitySet"` + RecoveryAvailabilityType string `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccount StorageAccountCustomDetails `json:"recoveryBootDiagStorageAccount"` + RecoveryLocation *string `json:"recoveryLocation,omitempty"` + RecoveryProximityPlacementGroup RecoveryProximityPlacementGroupCustomDetails `json:"recoveryProximityPlacementGroup"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoverySubscriptionId *string `json:"recoverySubscriptionId,omitempty"` + RecoveryVirtualNetwork RecoveryVirtualNetworkCustomDetails `json:"recoveryVirtualNetwork"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from ReplicationProtectionIntentProviderSpecificSettings +} + +var _ json.Marshaler = A2AReplicationIntentDetails{} + +func (s A2AReplicationIntentDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AReplicationIntentDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReplicationIntentDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReplicationIntentDetails: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReplicationIntentDetails: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &A2AReplicationIntentDetails{} + +func (s *A2AReplicationIntentDetails) UnmarshalJSON(bytes []byte) error { + type alias A2AReplicationIntentDetails + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into A2AReplicationIntentDetails: %+v", err) + } + + s.AgentAutoUpdateStatus = decoded.AgentAutoUpdateStatus + s.AutoProtectionOfDataDisk = decoded.AutoProtectionOfDataDisk + s.AutomationAccountArmId = decoded.AutomationAccountArmId + s.AutomationAccountAuthenticationType = decoded.AutomationAccountAuthenticationType + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.FabricObjectId = decoded.FabricObjectId + s.MultiVMGroupId = decoded.MultiVMGroupId + s.MultiVMGroupName = decoded.MultiVMGroupName + s.PrimaryLocation = decoded.PrimaryLocation + s.RecoveryAvailabilityType = decoded.RecoveryAvailabilityType + s.RecoveryAvailabilityZone = decoded.RecoveryAvailabilityZone + s.RecoveryLocation = decoded.RecoveryLocation + s.RecoveryResourceGroupId = decoded.RecoveryResourceGroupId + s.RecoverySubscriptionId = decoded.RecoverySubscriptionId + s.VMDisks = decoded.VMDisks + s.VMManagedDisks = decoded.VMManagedDisks + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AReplicationIntentDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccount"]; ok { + impl, err := unmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccount' for 'A2AReplicationIntentDetails': %+v", err) + } + s.PrimaryStagingStorageAccount = impl + } + + if v, ok := temp["protectionProfile"]; ok { + impl, err := unmarshalProtectionProfileCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProtectionProfile' for 'A2AReplicationIntentDetails': %+v", err) + } + s.ProtectionProfile = impl + } + + if v, ok := temp["recoveryAvailabilitySet"]; ok { + impl, err := unmarshalRecoveryAvailabilitySetCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAvailabilitySet' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryAvailabilitySet = impl + } + + if v, ok := temp["recoveryBootDiagStorageAccount"]; ok { + impl, err := unmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryBootDiagStorageAccount' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryBootDiagStorageAccount = impl + } + + if v, ok := temp["recoveryProximityPlacementGroup"]; ok { + impl, err := unmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryProximityPlacementGroup' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryProximityPlacementGroup = impl + } + + if v, ok := temp["recoveryVirtualNetwork"]; ok { + impl, err := unmarshalRecoveryVirtualNetworkCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryVirtualNetwork' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryVirtualNetwork = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentinput.go new file mode 100644 index 00000000000..043880b900a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentinput.go @@ -0,0 +1,8 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionIntentInput struct { + Properties *CreateProtectionIntentProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentproperties.go new file mode 100644 index 00000000000..82abb10ea69 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentproperties.go @@ -0,0 +1,32 @@ +package replicationprotectionintents + +import ( + "encoding/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 CreateProtectionIntentProperties struct { + ProviderSpecificDetails CreateProtectionIntentProviderSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &CreateProtectionIntentProperties{} + +func (s *CreateProtectionIntentProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionIntentProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalCreateProtectionIntentProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'CreateProtectionIntentProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go new file mode 100644 index 00000000000..b54af17cb31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go @@ -0,0 +1,53 @@ +package replicationprotectionintents + +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 CreateProtectionIntentProviderSpecificDetails interface { +} + +// RawCreateProtectionIntentProviderSpecificDetailsImpl 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 RawCreateProtectionIntentProviderSpecificDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalCreateProtectionIntentProviderSpecificDetailsImplementation(input []byte) (CreateProtectionIntentProviderSpecificDetails, 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 CreateProtectionIntentProviderSpecificDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2ACreateProtectionIntentInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACreateProtectionIntentInput: %+v", err) + } + return out, nil + } + + out := RawCreateProtectionIntentProviderSpecificDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_diskencryptioninfo.go new file mode 100644 index 00000000000..bbe499d7f6b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..1043673141e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingprotectionprofile.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingprotectionprofile.go new file mode 100644 index 00000000000..dbee810013d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingprotectionprofile.go @@ -0,0 +1,41 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionProfileCustomDetails = ExistingProtectionProfile{} + +type ExistingProtectionProfile struct { + ProtectionProfileId string `json:"protectionProfileId"` + + // Fields inherited from ProtectionProfileCustomDetails +} + +var _ json.Marshaler = ExistingProtectionProfile{} + +func (s ExistingProtectionProfile) MarshalJSON() ([]byte, error) { + type wrapper ExistingProtectionProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingProtectionProfile: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingProtectionProfile: %+v", err) + } + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingProtectionProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go new file mode 100644 index 00000000000..aa58d2d31a6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go @@ -0,0 +1,41 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryAvailabilitySetCustomDetails = ExistingRecoveryAvailabilitySet{} + +type ExistingRecoveryAvailabilitySet struct { + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + + // Fields inherited from RecoveryAvailabilitySetCustomDetails +} + +var _ json.Marshaler = ExistingRecoveryAvailabilitySet{} + +func (s ExistingRecoveryAvailabilitySet) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryAvailabilitySet + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go new file mode 100644 index 00000000000..e09469c79bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go @@ -0,0 +1,41 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryProximityPlacementGroupCustomDetails = ExistingRecoveryProximityPlacementGroup{} + +type ExistingRecoveryProximityPlacementGroup struct { + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + + // Fields inherited from RecoveryProximityPlacementGroupCustomDetails +} + +var _ json.Marshaler = ExistingRecoveryProximityPlacementGroup{} + +func (s ExistingRecoveryProximityPlacementGroup) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryProximityPlacementGroup + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go new file mode 100644 index 00000000000..05d6e88d647 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go @@ -0,0 +1,41 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryResourceGroupCustomDetails = ExistingRecoveryRecoveryResourceGroup{} + +type ExistingRecoveryRecoveryResourceGroup struct { + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + + // Fields inherited from RecoveryResourceGroupCustomDetails +} + +var _ json.Marshaler = ExistingRecoveryRecoveryResourceGroup{} + +func (s ExistingRecoveryRecoveryResourceGroup) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryRecoveryResourceGroup + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go new file mode 100644 index 00000000000..a8524773f2d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go @@ -0,0 +1,42 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryVirtualNetworkCustomDetails = ExistingRecoveryVirtualNetwork{} + +type ExistingRecoveryVirtualNetwork struct { + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + RecoveryVirtualNetworkId string `json:"recoveryVirtualNetworkId"` + + // Fields inherited from RecoveryVirtualNetworkCustomDetails +} + +var _ json.Marshaler = ExistingRecoveryVirtualNetwork{} + +func (s ExistingRecoveryVirtualNetwork) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryVirtualNetwork + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingstorageaccount.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingstorageaccount.go new file mode 100644 index 00000000000..4150f1c78d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_existingstorageaccount.go @@ -0,0 +1,41 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ StorageAccountCustomDetails = ExistingStorageAccount{} + +type ExistingStorageAccount struct { + AzureStorageAccountId string `json:"azureStorageAccountId"` + + // Fields inherited from StorageAccountCustomDetails +} + +var _ json.Marshaler = ExistingStorageAccount{} + +func (s ExistingStorageAccount) MarshalJSON() ([]byte, error) { + type wrapper ExistingStorageAccount + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingStorageAccount: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingStorageAccount: %+v", err) + } + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingStorageAccount: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..b4a8b6e0c54 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_newprotectionprofile.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_newprotectionprofile.go new file mode 100644 index 00000000000..9763db731fd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_newprotectionprofile.go @@ -0,0 +1,45 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionProfileCustomDetails = NewProtectionProfile{} + +type NewProtectionProfile struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + PolicyName string `json:"policyName"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + + // Fields inherited from ProtectionProfileCustomDetails +} + +var _ json.Marshaler = NewProtectionProfile{} + +func (s NewProtectionProfile) MarshalJSON() ([]byte, error) { + type wrapper NewProtectionProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NewProtectionProfile: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NewProtectionProfile: %+v", err) + } + decoded["resourceType"] = "New" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NewProtectionProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go new file mode 100644 index 00000000000..37ff485101c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go @@ -0,0 +1,42 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryVirtualNetworkCustomDetails = NewRecoveryVirtualNetwork{} + +type NewRecoveryVirtualNetwork struct { + RecoveryVirtualNetworkName *string `json:"recoveryVirtualNetworkName,omitempty"` + RecoveryVirtualNetworkResourceGroupName *string `json:"recoveryVirtualNetworkResourceGroupName,omitempty"` + + // Fields inherited from RecoveryVirtualNetworkCustomDetails +} + +var _ json.Marshaler = NewRecoveryVirtualNetwork{} + +func (s NewRecoveryVirtualNetwork) MarshalJSON() ([]byte, error) { + type wrapper NewRecoveryVirtualNetwork + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NewRecoveryVirtualNetwork: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NewRecoveryVirtualNetwork: %+v", err) + } + decoded["resourceType"] = "New" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NewRecoveryVirtualNetwork: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_protectionprofilecustomdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_protectionprofilecustomdetails.go new file mode 100644 index 00000000000..f7a1da7fa29 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_protectionprofilecustomdetails.go @@ -0,0 +1,61 @@ +package replicationprotectionintents + +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 ProtectionProfileCustomDetails interface { +} + +// RawProtectionProfileCustomDetailsImpl 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 RawProtectionProfileCustomDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionProfileCustomDetailsImplementation(input []byte) (ProtectionProfileCustomDetails, 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 ProtectionProfileCustomDetails into map[string]interface: %+v", err) + } + + value, ok := temp["resourceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Existing") { + var out ExistingProtectionProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingProtectionProfile: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "New") { + var out NewProtectionProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NewProtectionProfile: %+v", err) + } + return out, nil + } + + out := RawProtectionProfileCustomDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go new file mode 100644 index 00000000000..f3e97bf0f38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go @@ -0,0 +1,53 @@ +package replicationprotectionintents + +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 RecoveryAvailabilitySetCustomDetails interface { +} + +// RawRecoveryAvailabilitySetCustomDetailsImpl 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 RawRecoveryAvailabilitySetCustomDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryAvailabilitySetCustomDetailsImplementation(input []byte) (RecoveryAvailabilitySetCustomDetails, 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 RecoveryAvailabilitySetCustomDetails into map[string]interface: %+v", err) + } + + value, ok := temp["resourceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryAvailabilitySet + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryAvailabilitySet: %+v", err) + } + return out, nil + } + + out := RawRecoveryAvailabilitySetCustomDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go new file mode 100644 index 00000000000..a9a2ad54e69 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go @@ -0,0 +1,53 @@ +package replicationprotectionintents + +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 RecoveryProximityPlacementGroupCustomDetails interface { +} + +// RawRecoveryProximityPlacementGroupCustomDetailsImpl 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 RawRecoveryProximityPlacementGroupCustomDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(input []byte) (RecoveryProximityPlacementGroupCustomDetails, 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 RecoveryProximityPlacementGroupCustomDetails into map[string]interface: %+v", err) + } + + value, ok := temp["resourceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryProximityPlacementGroup + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryProximityPlacementGroup: %+v", err) + } + return out, nil + } + + out := RawRecoveryProximityPlacementGroupCustomDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go new file mode 100644 index 00000000000..702c573d04c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go @@ -0,0 +1,53 @@ +package replicationprotectionintents + +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 RecoveryResourceGroupCustomDetails interface { +} + +// RawRecoveryResourceGroupCustomDetailsImpl 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 RawRecoveryResourceGroupCustomDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryResourceGroupCustomDetailsImplementation(input []byte) (RecoveryResourceGroupCustomDetails, 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 RecoveryResourceGroupCustomDetails into map[string]interface: %+v", err) + } + + value, ok := temp["resourceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryRecoveryResourceGroup + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + return out, nil + } + + out := RawRecoveryResourceGroupCustomDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go new file mode 100644 index 00000000000..4649f35f1dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go @@ -0,0 +1,61 @@ +package replicationprotectionintents + +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 RecoveryVirtualNetworkCustomDetails interface { +} + +// RawRecoveryVirtualNetworkCustomDetailsImpl 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 RawRecoveryVirtualNetworkCustomDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryVirtualNetworkCustomDetailsImplementation(input []byte) (RecoveryVirtualNetworkCustomDetails, 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 RecoveryVirtualNetworkCustomDetails into map[string]interface: %+v", err) + } + + value, ok := temp["resourceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryVirtualNetwork + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryVirtualNetwork: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "New") { + var out NewRecoveryVirtualNetwork + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NewRecoveryVirtualNetwork: %+v", err) + } + return out, nil + } + + out := RawRecoveryVirtualNetworkCustomDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintent.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintent.go new file mode 100644 index 00000000000..1fbffaaf5ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintent.go @@ -0,0 +1,12 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionIntent struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationProtectionIntentProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintentproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintentproperties.go new file mode 100644 index 00000000000..5e15949e0fe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintentproperties.go @@ -0,0 +1,48 @@ +package replicationprotectionintents + +import ( + "encoding/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 ReplicationProtectionIntentProperties struct { + CreationTimeUTC *string `json:"creationTimeUTC,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobState *string `json:"jobState,omitempty"` + ProviderSpecificDetails ReplicationProtectionIntentProviderSpecificSettings `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReplicationProtectionIntentProperties{} + +func (s *ReplicationProtectionIntentProperties) UnmarshalJSON(bytes []byte) error { + type alias ReplicationProtectionIntentProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ReplicationProtectionIntentProperties: %+v", err) + } + + s.CreationTimeUTC = decoded.CreationTimeUTC + s.FriendlyName = decoded.FriendlyName + s.IsActive = decoded.IsActive + s.JobId = decoded.JobId + s.JobState = decoded.JobState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationProtectionIntentProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := unmarshalReplicationProtectionIntentProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationProtectionIntentProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go new file mode 100644 index 00000000000..899bca9364c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go @@ -0,0 +1,53 @@ +package replicationprotectionintents + +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 ReplicationProtectionIntentProviderSpecificSettings interface { +} + +// RawReplicationProtectionIntentProviderSpecificSettingsImpl 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 RawReplicationProtectionIntentProviderSpecificSettingsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalReplicationProtectionIntentProviderSpecificSettingsImplementation(input []byte) (ReplicationProtectionIntentProviderSpecificSettings, 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 ReplicationProtectionIntentProviderSpecificSettings into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AReplicationIntentDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReplicationIntentDetails: %+v", err) + } + return out, nil + } + + out := RawReplicationProtectionIntentProviderSpecificSettingsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_storageaccountcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_storageaccountcustomdetails.go new file mode 100644 index 00000000000..68675a90e21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/model_storageaccountcustomdetails.go @@ -0,0 +1,53 @@ +package replicationprotectionintents + +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 StorageAccountCustomDetails interface { +} + +// RawStorageAccountCustomDetailsImpl 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 RawStorageAccountCustomDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalStorageAccountCustomDetailsImplementation(input []byte) (StorageAccountCustomDetails, 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 StorageAccountCustomDetails into map[string]interface: %+v", err) + } + + value, ok := temp["resourceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Existing") { + var out ExistingStorageAccount + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingStorageAccount: %+v", err) + } + return out, nil + } + + out := RawStorageAccountCustomDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/predicates.go new file mode 100644 index 00000000000..9a372249403 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionIntentOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ReplicationProtectionIntentOperationPredicate) Matches(input ReplicationProtectionIntent) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/version.go new file mode 100644 index 00000000000..b1c18ae3429 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationprotectionintents/version.go @@ -0,0 +1,12 @@ +package replicationprotectionintents + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationprotectionintents/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/README.md new file mode 100644 index 00000000000..848890f764d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/README.md @@ -0,0 +1,203 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans` Documentation + +The `replicationrecoveryplans` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans" +``` + + +### Client Initialization + +```go +client := replicationrecoveryplans.NewReplicationRecoveryPlansClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Create` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +payload := replicationrecoveryplans.CreateRecoveryPlanInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Delete` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.FailoverCancel` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +if err := client.FailoverCancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.FailoverCommit` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +if err := client.FailoverCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Get` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +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: `ReplicationRecoveryPlansClient.List` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.PlannedFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +payload := replicationrecoveryplans.RecoveryPlanPlannedFailoverInput{ + // ... +} + + +if err := client.PlannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Reprotect` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +if err := client.ReprotectThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.TestFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +payload := replicationrecoveryplans.RecoveryPlanTestFailoverInput{ + // ... +} + + +if err := client.TestFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.TestFailoverCleanup` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +payload := replicationrecoveryplans.RecoveryPlanTestFailoverCleanupInput{ + // ... +} + + +if err := client.TestFailoverCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.UnplannedFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +payload := replicationrecoveryplans.RecoveryPlanUnplannedFailoverInput{ + // ... +} + + +if err := client.UnplannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Update` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + +payload := replicationrecoveryplans.UpdateRecoveryPlanInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/client.go new file mode 100644 index 00000000000..1718910fc8a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/client.go @@ -0,0 +1,26 @@ +package replicationrecoveryplans + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationRecoveryPlansClient struct { + Client *resourcemanager.Client +} + +func NewReplicationRecoveryPlansClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationRecoveryPlansClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationrecoveryplans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationRecoveryPlansClient: %+v", err) + } + + return &ReplicationRecoveryPlansClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/constants.go new file mode 100644 index 00000000000..3205b305372 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/constants.go @@ -0,0 +1,691 @@ +package replicationrecoveryplans + +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 A2ARpRecoveryPointType string + +const ( + A2ARpRecoveryPointTypeLatest A2ARpRecoveryPointType = "Latest" + A2ARpRecoveryPointTypeLatestApplicationConsistent A2ARpRecoveryPointType = "LatestApplicationConsistent" + A2ARpRecoveryPointTypeLatestCrashConsistent A2ARpRecoveryPointType = "LatestCrashConsistent" + A2ARpRecoveryPointTypeLatestProcessed A2ARpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForA2ARpRecoveryPointType() []string { + return []string{ + string(A2ARpRecoveryPointTypeLatest), + string(A2ARpRecoveryPointTypeLatestApplicationConsistent), + string(A2ARpRecoveryPointTypeLatestCrashConsistent), + string(A2ARpRecoveryPointTypeLatestProcessed), + } +} + +func (s *A2ARpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseA2ARpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseA2ARpRecoveryPointType(input string) (*A2ARpRecoveryPointType, error) { + vals := map[string]A2ARpRecoveryPointType{ + "latest": A2ARpRecoveryPointTypeLatest, + "latestapplicationconsistent": A2ARpRecoveryPointTypeLatestApplicationConsistent, + "latestcrashconsistent": A2ARpRecoveryPointTypeLatestCrashConsistent, + "latestprocessed": A2ARpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := A2ARpRecoveryPointType(input) + return &out, nil +} + +type AlternateLocationRecoveryOption string + +const ( + AlternateLocationRecoveryOptionCreateVMIfNotFound AlternateLocationRecoveryOption = "CreateVmIfNotFound" + AlternateLocationRecoveryOptionNoAction AlternateLocationRecoveryOption = "NoAction" +) + +func PossibleValuesForAlternateLocationRecoveryOption() []string { + return []string{ + string(AlternateLocationRecoveryOptionCreateVMIfNotFound), + string(AlternateLocationRecoveryOptionNoAction), + } +} + +func (s *AlternateLocationRecoveryOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlternateLocationRecoveryOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAlternateLocationRecoveryOption(input string) (*AlternateLocationRecoveryOption, error) { + vals := map[string]AlternateLocationRecoveryOption{ + "createvmifnotfound": AlternateLocationRecoveryOptionCreateVMIfNotFound, + "noaction": AlternateLocationRecoveryOptionNoAction, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AlternateLocationRecoveryOption(input) + return &out, nil +} + +type DataSyncStatus string + +const ( + DataSyncStatusForDownTime DataSyncStatus = "ForDownTime" + DataSyncStatusForSynchronization DataSyncStatus = "ForSynchronization" +) + +func PossibleValuesForDataSyncStatus() []string { + return []string{ + string(DataSyncStatusForDownTime), + string(DataSyncStatusForSynchronization), + } +} + +func (s *DataSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataSyncStatus(input string) (*DataSyncStatus, error) { + vals := map[string]DataSyncStatus{ + "fordowntime": DataSyncStatusForDownTime, + "forsynchronization": DataSyncStatusForSynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSyncStatus(input) + return &out, nil +} + +type FailoverDeploymentModel string + +const ( + FailoverDeploymentModelClassic FailoverDeploymentModel = "Classic" + FailoverDeploymentModelNotApplicable FailoverDeploymentModel = "NotApplicable" + FailoverDeploymentModelResourceManager FailoverDeploymentModel = "ResourceManager" +) + +func PossibleValuesForFailoverDeploymentModel() []string { + return []string{ + string(FailoverDeploymentModelClassic), + string(FailoverDeploymentModelNotApplicable), + string(FailoverDeploymentModelResourceManager), + } +} + +func (s *FailoverDeploymentModel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverDeploymentModel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverDeploymentModel(input string) (*FailoverDeploymentModel, error) { + vals := map[string]FailoverDeploymentModel{ + "classic": FailoverDeploymentModelClassic, + "notapplicable": FailoverDeploymentModelNotApplicable, + "resourcemanager": FailoverDeploymentModelResourceManager, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverDeploymentModel(input) + return &out, nil +} + +type HyperVReplicaAzureRpRecoveryPointType string + +const ( + HyperVReplicaAzureRpRecoveryPointTypeLatest HyperVReplicaAzureRpRecoveryPointType = "Latest" + HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent HyperVReplicaAzureRpRecoveryPointType = "LatestApplicationConsistent" + HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed HyperVReplicaAzureRpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForHyperVReplicaAzureRpRecoveryPointType() []string { + return []string{ + string(HyperVReplicaAzureRpRecoveryPointTypeLatest), + string(HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent), + string(HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed), + } +} + +func (s *HyperVReplicaAzureRpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHyperVReplicaAzureRpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHyperVReplicaAzureRpRecoveryPointType(input string) (*HyperVReplicaAzureRpRecoveryPointType, error) { + vals := map[string]HyperVReplicaAzureRpRecoveryPointType{ + "latest": HyperVReplicaAzureRpRecoveryPointTypeLatest, + "latestapplicationconsistent": HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent, + "latestprocessed": HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HyperVReplicaAzureRpRecoveryPointType(input) + return &out, nil +} + +type InMageRcmFailbackRecoveryPointType string + +const ( + InMageRcmFailbackRecoveryPointTypeApplicationConsistent InMageRcmFailbackRecoveryPointType = "ApplicationConsistent" + InMageRcmFailbackRecoveryPointTypeCrashConsistent InMageRcmFailbackRecoveryPointType = "CrashConsistent" +) + +func PossibleValuesForInMageRcmFailbackRecoveryPointType() []string { + return []string{ + string(InMageRcmFailbackRecoveryPointTypeApplicationConsistent), + string(InMageRcmFailbackRecoveryPointTypeCrashConsistent), + } +} + +func (s *InMageRcmFailbackRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageRcmFailbackRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageRcmFailbackRecoveryPointType(input string) (*InMageRcmFailbackRecoveryPointType, error) { + vals := map[string]InMageRcmFailbackRecoveryPointType{ + "applicationconsistent": InMageRcmFailbackRecoveryPointTypeApplicationConsistent, + "crashconsistent": InMageRcmFailbackRecoveryPointTypeCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageRcmFailbackRecoveryPointType(input) + return &out, nil +} + +type InMageV2RpRecoveryPointType string + +const ( + InMageV2RpRecoveryPointTypeLatest InMageV2RpRecoveryPointType = "Latest" + InMageV2RpRecoveryPointTypeLatestApplicationConsistent InMageV2RpRecoveryPointType = "LatestApplicationConsistent" + InMageV2RpRecoveryPointTypeLatestCrashConsistent InMageV2RpRecoveryPointType = "LatestCrashConsistent" + InMageV2RpRecoveryPointTypeLatestProcessed InMageV2RpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForInMageV2RpRecoveryPointType() []string { + return []string{ + string(InMageV2RpRecoveryPointTypeLatest), + string(InMageV2RpRecoveryPointTypeLatestApplicationConsistent), + string(InMageV2RpRecoveryPointTypeLatestCrashConsistent), + string(InMageV2RpRecoveryPointTypeLatestProcessed), + } +} + +func (s *InMageV2RpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageV2RpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageV2RpRecoveryPointType(input string) (*InMageV2RpRecoveryPointType, error) { + vals := map[string]InMageV2RpRecoveryPointType{ + "latest": InMageV2RpRecoveryPointTypeLatest, + "latestapplicationconsistent": InMageV2RpRecoveryPointTypeLatestApplicationConsistent, + "latestcrashconsistent": InMageV2RpRecoveryPointTypeLatestCrashConsistent, + "latestprocessed": InMageV2RpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageV2RpRecoveryPointType(input) + return &out, nil +} + +type MultiVMSyncPointOption string + +const ( + MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint MultiVMSyncPointOption = "UseMultiVmSyncRecoveryPoint" + MultiVMSyncPointOptionUsePerVMRecoveryPoint MultiVMSyncPointOption = "UsePerVmRecoveryPoint" +) + +func PossibleValuesForMultiVMSyncPointOption() []string { + return []string{ + string(MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint), + string(MultiVMSyncPointOptionUsePerVMRecoveryPoint), + } +} + +func (s *MultiVMSyncPointOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiVMSyncPointOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiVMSyncPointOption(input string) (*MultiVMSyncPointOption, error) { + vals := map[string]MultiVMSyncPointOption{ + "usemultivmsyncrecoverypoint": MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint, + "usepervmrecoverypoint": MultiVMSyncPointOptionUsePerVMRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiVMSyncPointOption(input) + return &out, nil +} + +type PossibleOperationsDirections string + +const ( + PossibleOperationsDirectionsPrimaryToRecovery PossibleOperationsDirections = "PrimaryToRecovery" + PossibleOperationsDirectionsRecoveryToPrimary PossibleOperationsDirections = "RecoveryToPrimary" +) + +func PossibleValuesForPossibleOperationsDirections() []string { + return []string{ + string(PossibleOperationsDirectionsPrimaryToRecovery), + string(PossibleOperationsDirectionsRecoveryToPrimary), + } +} + +func (s *PossibleOperationsDirections) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePossibleOperationsDirections(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePossibleOperationsDirections(input string) (*PossibleOperationsDirections, error) { + vals := map[string]PossibleOperationsDirections{ + "primarytorecovery": PossibleOperationsDirectionsPrimaryToRecovery, + "recoverytoprimary": PossibleOperationsDirectionsRecoveryToPrimary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PossibleOperationsDirections(input) + return &out, nil +} + +type RecoveryPlanActionLocation string + +const ( + RecoveryPlanActionLocationPrimary RecoveryPlanActionLocation = "Primary" + RecoveryPlanActionLocationRecovery RecoveryPlanActionLocation = "Recovery" +) + +func PossibleValuesForRecoveryPlanActionLocation() []string { + return []string{ + string(RecoveryPlanActionLocationPrimary), + string(RecoveryPlanActionLocationRecovery), + } +} + +func (s *RecoveryPlanActionLocation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanActionLocation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanActionLocation(input string) (*RecoveryPlanActionLocation, error) { + vals := map[string]RecoveryPlanActionLocation{ + "primary": RecoveryPlanActionLocationPrimary, + "recovery": RecoveryPlanActionLocationRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanActionLocation(input) + return &out, nil +} + +type RecoveryPlanGroupType string + +const ( + RecoveryPlanGroupTypeBoot RecoveryPlanGroupType = "Boot" + RecoveryPlanGroupTypeFailover RecoveryPlanGroupType = "Failover" + RecoveryPlanGroupTypeShutdown RecoveryPlanGroupType = "Shutdown" +) + +func PossibleValuesForRecoveryPlanGroupType() []string { + return []string{ + string(RecoveryPlanGroupTypeBoot), + string(RecoveryPlanGroupTypeFailover), + string(RecoveryPlanGroupTypeShutdown), + } +} + +func (s *RecoveryPlanGroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanGroupType(input string) (*RecoveryPlanGroupType, error) { + vals := map[string]RecoveryPlanGroupType{ + "boot": RecoveryPlanGroupTypeBoot, + "failover": RecoveryPlanGroupTypeFailover, + "shutdown": RecoveryPlanGroupTypeShutdown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanGroupType(input) + return &out, nil +} + +type RecoveryPlanPointType string + +const ( + RecoveryPlanPointTypeLatest RecoveryPlanPointType = "Latest" + RecoveryPlanPointTypeLatestApplicationConsistent RecoveryPlanPointType = "LatestApplicationConsistent" + RecoveryPlanPointTypeLatestCrashConsistent RecoveryPlanPointType = "LatestCrashConsistent" + RecoveryPlanPointTypeLatestProcessed RecoveryPlanPointType = "LatestProcessed" +) + +func PossibleValuesForRecoveryPlanPointType() []string { + return []string{ + string(RecoveryPlanPointTypeLatest), + string(RecoveryPlanPointTypeLatestApplicationConsistent), + string(RecoveryPlanPointTypeLatestCrashConsistent), + string(RecoveryPlanPointTypeLatestProcessed), + } +} + +func (s *RecoveryPlanPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanPointType(input string) (*RecoveryPlanPointType, error) { + vals := map[string]RecoveryPlanPointType{ + "latest": RecoveryPlanPointTypeLatest, + "latestapplicationconsistent": RecoveryPlanPointTypeLatestApplicationConsistent, + "latestcrashconsistent": RecoveryPlanPointTypeLatestCrashConsistent, + "latestprocessed": RecoveryPlanPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanPointType(input) + return &out, nil +} + +type ReplicationProtectedItemOperation string + +const ( + ReplicationProtectedItemOperationCancelFailover ReplicationProtectedItemOperation = "CancelFailover" + ReplicationProtectedItemOperationChangePit ReplicationProtectedItemOperation = "ChangePit" + ReplicationProtectedItemOperationCommit ReplicationProtectedItemOperation = "Commit" + ReplicationProtectedItemOperationCompleteMigration ReplicationProtectedItemOperation = "CompleteMigration" + ReplicationProtectedItemOperationDisableProtection ReplicationProtectedItemOperation = "DisableProtection" + ReplicationProtectedItemOperationFailback ReplicationProtectedItemOperation = "Failback" + ReplicationProtectedItemOperationFinalizeFailback ReplicationProtectedItemOperation = "FinalizeFailback" + ReplicationProtectedItemOperationPlannedFailover ReplicationProtectedItemOperation = "PlannedFailover" + ReplicationProtectedItemOperationRepairReplication ReplicationProtectedItemOperation = "RepairReplication" + ReplicationProtectedItemOperationReverseReplicate ReplicationProtectedItemOperation = "ReverseReplicate" + ReplicationProtectedItemOperationSwitchProtection ReplicationProtectedItemOperation = "SwitchProtection" + ReplicationProtectedItemOperationTestFailover ReplicationProtectedItemOperation = "TestFailover" + ReplicationProtectedItemOperationTestFailoverCleanup ReplicationProtectedItemOperation = "TestFailoverCleanup" + ReplicationProtectedItemOperationUnplannedFailover ReplicationProtectedItemOperation = "UnplannedFailover" +) + +func PossibleValuesForReplicationProtectedItemOperation() []string { + return []string{ + string(ReplicationProtectedItemOperationCancelFailover), + string(ReplicationProtectedItemOperationChangePit), + string(ReplicationProtectedItemOperationCommit), + string(ReplicationProtectedItemOperationCompleteMigration), + string(ReplicationProtectedItemOperationDisableProtection), + string(ReplicationProtectedItemOperationFailback), + string(ReplicationProtectedItemOperationFinalizeFailback), + string(ReplicationProtectedItemOperationPlannedFailover), + string(ReplicationProtectedItemOperationRepairReplication), + string(ReplicationProtectedItemOperationReverseReplicate), + string(ReplicationProtectedItemOperationSwitchProtection), + string(ReplicationProtectedItemOperationTestFailover), + string(ReplicationProtectedItemOperationTestFailoverCleanup), + string(ReplicationProtectedItemOperationUnplannedFailover), + } +} + +func (s *ReplicationProtectedItemOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationProtectedItemOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationProtectedItemOperation(input string) (*ReplicationProtectedItemOperation, error) { + vals := map[string]ReplicationProtectedItemOperation{ + "cancelfailover": ReplicationProtectedItemOperationCancelFailover, + "changepit": ReplicationProtectedItemOperationChangePit, + "commit": ReplicationProtectedItemOperationCommit, + "completemigration": ReplicationProtectedItemOperationCompleteMigration, + "disableprotection": ReplicationProtectedItemOperationDisableProtection, + "failback": ReplicationProtectedItemOperationFailback, + "finalizefailback": ReplicationProtectedItemOperationFinalizeFailback, + "plannedfailover": ReplicationProtectedItemOperationPlannedFailover, + "repairreplication": ReplicationProtectedItemOperationRepairReplication, + "reversereplicate": ReplicationProtectedItemOperationReverseReplicate, + "switchprotection": ReplicationProtectedItemOperationSwitchProtection, + "testfailover": ReplicationProtectedItemOperationTestFailover, + "testfailovercleanup": ReplicationProtectedItemOperationTestFailoverCleanup, + "unplannedfailover": ReplicationProtectedItemOperationUnplannedFailover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationProtectedItemOperation(input) + return &out, nil +} + +type RpInMageRecoveryPointType string + +const ( + RpInMageRecoveryPointTypeCustom RpInMageRecoveryPointType = "Custom" + RpInMageRecoveryPointTypeLatestTag RpInMageRecoveryPointType = "LatestTag" + RpInMageRecoveryPointTypeLatestTime RpInMageRecoveryPointType = "LatestTime" +) + +func PossibleValuesForRpInMageRecoveryPointType() []string { + return []string{ + string(RpInMageRecoveryPointTypeCustom), + string(RpInMageRecoveryPointTypeLatestTag), + string(RpInMageRecoveryPointTypeLatestTime), + } +} + +func (s *RpInMageRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRpInMageRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRpInMageRecoveryPointType(input string) (*RpInMageRecoveryPointType, error) { + vals := map[string]RpInMageRecoveryPointType{ + "custom": RpInMageRecoveryPointTypeCustom, + "latesttag": RpInMageRecoveryPointTypeLatestTag, + "latesttime": RpInMageRecoveryPointTypeLatestTime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RpInMageRecoveryPointType(input) + return &out, nil +} + +type SourceSiteOperations string + +const ( + SourceSiteOperationsNotRequired SourceSiteOperations = "NotRequired" + SourceSiteOperationsRequired SourceSiteOperations = "Required" +) + +func PossibleValuesForSourceSiteOperations() []string { + return []string{ + string(SourceSiteOperationsNotRequired), + string(SourceSiteOperationsRequired), + } +} + +func (s *SourceSiteOperations) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceSiteOperations(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceSiteOperations(input string) (*SourceSiteOperations, error) { + vals := map[string]SourceSiteOperations{ + "notrequired": SourceSiteOperationsNotRequired, + "required": SourceSiteOperationsRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceSiteOperations(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_replicationrecoveryplan.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_replicationrecoveryplan.go new file mode 100644 index 00000000000..9b7f3ccf056 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_replicationrecoveryplan.go @@ -0,0 +1,134 @@ +package replicationrecoveryplans + +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 = &ReplicationRecoveryPlanId{} + +// ReplicationRecoveryPlanId is a struct representing the Resource ID for a Replication Recovery Plan +type ReplicationRecoveryPlanId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationRecoveryPlanName string +} + +// NewReplicationRecoveryPlanID returns a new ReplicationRecoveryPlanId struct +func NewReplicationRecoveryPlanID(subscriptionId string, resourceGroupName string, vaultName string, replicationRecoveryPlanName string) ReplicationRecoveryPlanId { + return ReplicationRecoveryPlanId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationRecoveryPlanName: replicationRecoveryPlanName, + } +} + +// ParseReplicationRecoveryPlanID parses 'input' into a ReplicationRecoveryPlanId +func ParseReplicationRecoveryPlanID(input string) (*ReplicationRecoveryPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryPlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryPlanId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationRecoveryPlanIDInsensitively parses 'input' case-insensitively into a ReplicationRecoveryPlanId +// note: this method should only be used for API response data and not user input +func ParseReplicationRecoveryPlanIDInsensitively(input string) (*ReplicationRecoveryPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryPlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryPlanId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationRecoveryPlanId) 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.ReplicationRecoveryPlanName, ok = input.Parsed["replicationRecoveryPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationRecoveryPlanName", input) + } + + return nil +} + +// ValidateReplicationRecoveryPlanID checks that 'input' can be parsed as a Replication Recovery Plan ID +func ValidateReplicationRecoveryPlanID(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 := ParseReplicationRecoveryPlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationRecoveryPlans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationRecoveryPlanName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) 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("staticReplicationRecoveryPlans", "replicationRecoveryPlans", "replicationRecoveryPlans"), + resourceids.UserSpecifiedSegment("replicationRecoveryPlanName", "replicationRecoveryPlanValue"), + } +} + +// String returns a human-readable description of this Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) 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("Replication Recovery Plan Name: %q", id.ReplicationRecoveryPlanName), + } + return fmt.Sprintf("Replication Recovery Plan (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go new file mode 100644 index 00000000000..b04294d1a4a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go @@ -0,0 +1,327 @@ +package replicationrecoveryplans + +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 = &ReplicationRecoveryPlanId{} + +func TestNewReplicationRecoveryPlanID(t *testing.T) { + id := NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue") + + 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.ReplicationRecoveryPlanName != "replicationRecoveryPlanValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationRecoveryPlanName'", id.ReplicationRecoveryPlanName, "replicationRecoveryPlanValue") + } +} + +func TestFormatReplicationRecoveryPlanID(t *testing.T) { + actual := NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationRecoveryPlanValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationRecoveryPlans/replicationRecoveryPlanValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationRecoveryPlanID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryPlanId + }{ + { + // 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/replicationRecoveryPlans", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationRecoveryPlans/replicationRecoveryPlanValue", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationRecoveryPlanName: "replicationRecoveryPlanValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationRecoveryPlans/replicationRecoveryPlanValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryPlanID(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.ReplicationRecoveryPlanName != v.Expected.ReplicationRecoveryPlanName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryPlanName", v.Expected.ReplicationRecoveryPlanName, actual.ReplicationRecoveryPlanName) + } + + } +} + +func TestParseReplicationRecoveryPlanIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryPlanId + }{ + { + // 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/replicationRecoveryPlans", + Error: 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/rEpLiCaTiOnReCoVeRyPlAnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationRecoveryPlans/replicationRecoveryPlanValue", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationRecoveryPlanName: "replicationRecoveryPlanValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationRecoveryPlans/replicationRecoveryPlanValue/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/rEpLiCaTiOnReCoVeRyPlAnS/rEpLiCaTiOnReCoVeRyPlAnVaLuE", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationRecoveryPlanName: "rEpLiCaTiOnReCoVeRyPlAnVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnReCoVeRyPlAnS/rEpLiCaTiOnReCoVeRyPlAnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryPlanIDInsensitively(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.ReplicationRecoveryPlanName != v.Expected.ReplicationRecoveryPlanName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryPlanName", v.Expected.ReplicationRecoveryPlanName, actual.ReplicationRecoveryPlanName) + } + + } +} + +func TestSegmentsForReplicationRecoveryPlanId(t *testing.T) { + segments := ReplicationRecoveryPlanId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationRecoveryPlanId 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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_vault.go new file mode 100644 index 00000000000..35811b70fe0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_vault.go @@ -0,0 +1,125 @@ +package replicationrecoveryplans + +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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_vault_test.go new file mode 100644 index 00000000000..86445039ab8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationrecoveryplans + +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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_create.go new file mode 100644 index 00000000000..208bd2e921a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_create.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// Create ... +func (c ReplicationRecoveryPlansClient) Create(ctx context.Context, id ReplicationRecoveryPlanId, input CreateRecoveryPlanInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationRecoveryPlansClient) CreateThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input CreateRecoveryPlanInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_delete.go new file mode 100644 index 00000000000..361ccfa4989 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_delete.go @@ -0,0 +1,70 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationRecoveryPlansClient) Delete(ctx context.Context, id ReplicationRecoveryPlanId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationRecoveryPlansClient) DeleteThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_failovercancel.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_failovercancel.go new file mode 100644 index 00000000000..cdd458efe6e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_failovercancel.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCancelOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// FailoverCancel ... +func (c ReplicationRecoveryPlansClient) FailoverCancel(ctx context.Context, id ReplicationRecoveryPlanId) (result FailoverCancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCancel", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCancelThenPoll performs FailoverCancel then polls until it's completed +func (c ReplicationRecoveryPlansClient) FailoverCancelThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.FailoverCancel(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_failovercommit.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_failovercommit.go new file mode 100644 index 00000000000..616be805c7c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_failovercommit.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// FailoverCommit ... +func (c ReplicationRecoveryPlansClient) FailoverCommit(ctx context.Context, id ReplicationRecoveryPlanId) (result FailoverCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCommit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCommitThenPoll performs FailoverCommit then polls until it's completed +func (c ReplicationRecoveryPlansClient) FailoverCommitThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.FailoverCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_get.go new file mode 100644 index 00000000000..a87a26e2045 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_get.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// Get ... +func (c ReplicationRecoveryPlansClient) Get(ctx context.Context, id ReplicationRecoveryPlanId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_list.go new file mode 100644 index 00000000000..d3bb62ca4a6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_list.go @@ -0,0 +1,91 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryPlan +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryPlan +} + +// List ... +func (c ReplicationRecoveryPlansClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationRecoveryPlans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecoveryPlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationRecoveryPlansClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RecoveryPlanOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryPlansClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate RecoveryPlanOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RecoveryPlan, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_plannedfailover.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_plannedfailover.go new file mode 100644 index 00000000000..9e199f4febe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_plannedfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// PlannedFailover ... +func (c ReplicationRecoveryPlansClient) PlannedFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanPlannedFailoverInput) (result PlannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/plannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PlannedFailoverThenPoll performs PlannedFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) PlannedFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanPlannedFailoverInput) error { + result, err := c.PlannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PlannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PlannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_reprotect.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_reprotect.go new file mode 100644 index 00000000000..4ba2693d77c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_reprotect.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReprotectOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// Reprotect ... +func (c ReplicationRecoveryPlansClient) Reprotect(ctx context.Context, id ReplicationRecoveryPlanId) (result ReprotectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reProtect", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReprotectThenPoll performs Reprotect then polls until it's completed +func (c ReplicationRecoveryPlansClient) ReprotectThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.Reprotect(ctx, id) + if err != nil { + return fmt.Errorf("performing Reprotect: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reprotect: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_testfailover.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_testfailover.go new file mode 100644 index 00000000000..5ce4c216166 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_testfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// TestFailover ... +func (c ReplicationRecoveryPlansClient) TestFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverInput) (result TestFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverThenPoll performs TestFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) TestFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverInput) error { + result, err := c.TestFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_testfailovercleanup.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_testfailovercleanup.go new file mode 100644 index 00000000000..77c89a02297 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_testfailovercleanup.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// TestFailoverCleanup ... +func (c ReplicationRecoveryPlansClient) TestFailoverCleanup(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverCleanupInput) (result TestFailoverCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailoverCleanup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverCleanupThenPoll performs TestFailoverCleanup then polls until it's completed +func (c ReplicationRecoveryPlansClient) TestFailoverCleanupThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverCleanupInput) error { + result, err := c.TestFailoverCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailoverCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailoverCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_unplannedfailover.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_unplannedfailover.go new file mode 100644 index 00000000000..a2c4fe6c90d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_unplannedfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// UnplannedFailover ... +func (c ReplicationRecoveryPlansClient) UnplannedFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanUnplannedFailoverInput) (result UnplannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unplannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UnplannedFailoverThenPoll performs UnplannedFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) UnplannedFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanUnplannedFailoverInput) error { + result, err := c.UnplannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnplannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnplannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_update.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_update.go new file mode 100644 index 00000000000..45c17f2850c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/method_update.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// Update ... +func (c ReplicationRecoveryPlansClient) Update(ctx context.Context, id ReplicationRecoveryPlanId, input UpdateRecoveryPlanInput) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ReplicationRecoveryPlansClient) UpdateThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input UpdateRecoveryPlanInput) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_createrecoveryplaninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_createrecoveryplaninput.go new file mode 100644 index 00000000000..283b7b90f39 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_createrecoveryplaninput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateRecoveryPlanInput struct { + Properties CreateRecoveryPlanInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go new file mode 100644 index 00000000000..cd2989da2de --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go @@ -0,0 +1,55 @@ +package replicationrecoveryplans + +import ( + "encoding/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 CreateRecoveryPlanInputProperties struct { + FailoverDeploymentModel *FailoverDeploymentModel `json:"failoverDeploymentModel,omitempty"` + Groups []RecoveryPlanGroup `json:"groups"` + PrimaryFabricId string `json:"primaryFabricId"` + ProviderSpecificInput *[]RecoveryPlanProviderSpecificInput `json:"providerSpecificInput,omitempty"` + RecoveryFabricId string `json:"recoveryFabricId"` +} + +var _ json.Unmarshaler = &CreateRecoveryPlanInputProperties{} + +func (s *CreateRecoveryPlanInputProperties) UnmarshalJSON(bytes []byte) error { + type alias CreateRecoveryPlanInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into CreateRecoveryPlanInputProperties: %+v", err) + } + + s.FailoverDeploymentModel = decoded.FailoverDeploymentModel + s.Groups = decoded.Groups + s.PrimaryFabricId = decoded.PrimaryFabricId + s.RecoveryFabricId = decoded.RecoveryFabricId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateRecoveryPlanInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificInput into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificInput, 0) + for i, val := range listTemp { + impl, err := unmarshalRecoveryPlanProviderSpecificInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificInput' for 'CreateRecoveryPlanInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificInput = &output + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_currentscenariodetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_currentscenariodetails.go new file mode 100644 index 00000000000..fbcd02e69f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_currentscenariodetails.go @@ -0,0 +1,28 @@ +package replicationrecoveryplans + +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 CurrentScenarioDetails struct { + JobId *string `json:"jobId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentScenarioDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentScenarioDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplan.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplan.go new file mode 100644 index 00000000000..f2f8f5ac73f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplan.go @@ -0,0 +1,12 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlan struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryPlanProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2adetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2adetails.go new file mode 100644 index 00000000000..4c00474efd5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2adetails.go @@ -0,0 +1,46 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificDetails = RecoveryPlanA2ADetails{} + +type RecoveryPlanA2ADetails struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificDetails +} + +var _ json.Marshaler = RecoveryPlanA2ADetails{} + +func (s RecoveryPlanA2ADetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2ADetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2ADetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2ADetails: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2ADetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go new file mode 100644 index 00000000000..ed65da3bfd6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go @@ -0,0 +1,43 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanA2AFailoverInput{} + +type RecoveryPlanA2AFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + MultiVMSyncPointOption *MultiVMSyncPointOption `json:"multiVmSyncPointOption,omitempty"` + RecoveryPointType A2ARpRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput +} + +var _ json.Marshaler = RecoveryPlanA2AFailoverInput{} + +func (s RecoveryPlanA2AFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2AFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2ainput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2ainput.go new file mode 100644 index 00000000000..ff7269aea88 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplana2ainput.go @@ -0,0 +1,46 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificInput = RecoveryPlanA2AInput{} + +type RecoveryPlanA2AInput struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificInput +} + +var _ json.Marshaler = RecoveryPlanA2AInput{} + +func (s RecoveryPlanA2AInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2AInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2AInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2AInput: %+v", err) + } + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2AInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanaction.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanaction.go new file mode 100644 index 00000000000..48d149ecce5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanaction.go @@ -0,0 +1,44 @@ +package replicationrecoveryplans + +import ( + "encoding/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 RecoveryPlanAction struct { + ActionName string `json:"actionName"` + CustomDetails RecoveryPlanActionDetails `json:"customDetails"` + FailoverDirections []PossibleOperationsDirections `json:"failoverDirections"` + FailoverTypes []ReplicationProtectedItemOperation `json:"failoverTypes"` +} + +var _ json.Unmarshaler = &RecoveryPlanAction{} + +func (s *RecoveryPlanAction) UnmarshalJSON(bytes []byte) error { + type alias RecoveryPlanAction + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPlanAction: %+v", err) + } + + s.ActionName = decoded.ActionName + s.FailoverDirections = decoded.FailoverDirections + s.FailoverTypes = decoded.FailoverTypes + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanAction into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := unmarshalRecoveryPlanActionDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'RecoveryPlanAction': %+v", err) + } + s.CustomDetails = impl + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanactiondetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanactiondetails.go new file mode 100644 index 00000000000..8743f523c01 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanactiondetails.go @@ -0,0 +1,69 @@ +package replicationrecoveryplans + +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 RecoveryPlanActionDetails interface { +} + +// RawRecoveryPlanActionDetailsImpl 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 RawRecoveryPlanActionDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryPlanActionDetailsImplementation(input []byte) (RecoveryPlanActionDetails, 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 RecoveryPlanActionDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AutomationRunbookActionDetails") { + var out RecoveryPlanAutomationRunbookActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManualActionDetails") { + var out RecoveryPlanManualActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanManualActionDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScriptActionDetails") { + var out RecoveryPlanScriptActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanScriptActionDetails: %+v", err) + } + return out, nil + } + + out := RawRecoveryPlanActionDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go new file mode 100644 index 00000000000..58750909e96 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go @@ -0,0 +1,43 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanActionDetails = RecoveryPlanAutomationRunbookActionDetails{} + +type RecoveryPlanAutomationRunbookActionDetails struct { + FabricLocation RecoveryPlanActionLocation `json:"fabricLocation"` + RunbookId *string `json:"runbookId,omitempty"` + Timeout *string `json:"timeout,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails +} + +var _ json.Marshaler = RecoveryPlanAutomationRunbookActionDetails{} + +func (s RecoveryPlanAutomationRunbookActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanAutomationRunbookActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + decoded["instanceType"] = "AutomationRunbookActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplangroup.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplangroup.go new file mode 100644 index 00000000000..9100cabc9e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplangroup.go @@ -0,0 +1,11 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanGroup struct { + EndGroupActions *[]RecoveryPlanAction `json:"endGroupActions,omitempty"` + GroupType RecoveryPlanGroupType `json:"groupType"` + ReplicationProtectedItems *[]RecoveryPlanProtectedItem `json:"replicationProtectedItems,omitempty"` + StartGroupActions *[]RecoveryPlanAction `json:"startGroupActions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go new file mode 100644 index 00000000000..eeda143cee0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go @@ -0,0 +1,42 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanHyperVReplicaAzureFailbackInput{} + +type RecoveryPlanHyperVReplicaAzureFailbackInput struct { + DataSyncOption DataSyncStatus `json:"dataSyncOption"` + RecoveryVMCreationOption AlternateLocationRecoveryOption `json:"recoveryVmCreationOption"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput +} + +var _ json.Marshaler = RecoveryPlanHyperVReplicaAzureFailbackInput{} + +func (s RecoveryPlanHyperVReplicaAzureFailbackInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanHyperVReplicaAzureFailbackInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzureFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go new file mode 100644 index 00000000000..5a0fe3870cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go @@ -0,0 +1,43 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanHyperVReplicaAzureFailoverInput{} + +type RecoveryPlanHyperVReplicaAzureFailoverInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointType *HyperVReplicaAzureRpRecoveryPointType `json:"recoveryPointType,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput +} + +var _ json.Marshaler = RecoveryPlanHyperVReplicaAzureFailoverInput{} + +func (s RecoveryPlanHyperVReplicaAzureFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanHyperVReplicaAzureFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go new file mode 100644 index 00000000000..a69c322e830 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go @@ -0,0 +1,42 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageAzureV2FailoverInput{} + +type RecoveryPlanInMageAzureV2FailoverInput struct { + RecoveryPointType InMageV2RpRecoveryPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput +} + +var _ json.Marshaler = RecoveryPlanInMageAzureV2FailoverInput{} + +func (s RecoveryPlanInMageAzureV2FailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageAzureV2FailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go new file mode 100644 index 00000000000..f9a288c0d63 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go @@ -0,0 +1,41 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageFailoverInput{} + +type RecoveryPlanInMageFailoverInput struct { + RecoveryPointType RpInMageRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput +} + +var _ json.Marshaler = RecoveryPlanInMageFailoverInput{} + +func (s RecoveryPlanInMageFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go new file mode 100644 index 00000000000..cf4ee99187e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go @@ -0,0 +1,42 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageRcmFailbackFailoverInput{} + +type RecoveryPlanInMageRcmFailbackFailoverInput struct { + RecoveryPointType InMageRcmFailbackRecoveryPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput +} + +var _ json.Marshaler = RecoveryPlanInMageRcmFailbackFailoverInput{} + +func (s RecoveryPlanInMageRcmFailbackFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageRcmFailbackFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go new file mode 100644 index 00000000000..eace4ab2d6c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go @@ -0,0 +1,42 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageRcmFailoverInput{} + +type RecoveryPlanInMageRcmFailoverInput struct { + RecoveryPointType RecoveryPlanPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput +} + +var _ json.Marshaler = RecoveryPlanInMageRcmFailoverInput{} + +func (s RecoveryPlanInMageRcmFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageRcmFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go new file mode 100644 index 00000000000..09234f4e823 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go @@ -0,0 +1,41 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanActionDetails = RecoveryPlanManualActionDetails{} + +type RecoveryPlanManualActionDetails struct { + Description *string `json:"description,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails +} + +var _ json.Marshaler = RecoveryPlanManualActionDetails{} + +func (s RecoveryPlanManualActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanManualActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanManualActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanManualActionDetails: %+v", err) + } + decoded["instanceType"] = "ManualActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanManualActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go new file mode 100644 index 00000000000..5afa04d9119 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanPlannedFailoverInput struct { + Properties RecoveryPlanPlannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go new file mode 100644 index 00000000000..f4e94fedb5b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go @@ -0,0 +1,49 @@ +package replicationrecoveryplans + +import ( + "encoding/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 RecoveryPlanPlannedFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPlanPlannedFailoverInputProperties{} + +func (s *RecoveryPlanPlannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + type alias RecoveryPlanPlannedFailoverInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPlanPlannedFailoverInputProperties: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanPlannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := unmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanPlannedFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproperties.go new file mode 100644 index 00000000000..76d17795541 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproperties.go @@ -0,0 +1,116 @@ +package replicationrecoveryplans + +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. + +type RecoveryPlanProperties struct { + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + CurrentScenarioStatus *string `json:"currentScenarioStatus,omitempty"` + CurrentScenarioStatusDescription *string `json:"currentScenarioStatusDescription,omitempty"` + FailoverDeploymentModel *string `json:"failoverDeploymentModel,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` + LastPlannedFailoverTime *string `json:"lastPlannedFailoverTime,omitempty"` + LastTestFailoverTime *string `json:"lastTestFailoverTime,omitempty"` + LastUnplannedFailoverTime *string `json:"lastUnplannedFailoverTime,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricId *string `json:"primaryFabricId,omitempty"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificDetails `json:"providerSpecificDetails,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + ReplicationProviders *[]string `json:"replicationProviders,omitempty"` +} + +func (o *RecoveryPlanProperties) GetLastPlannedFailoverTimeAsTime() (*time.Time, error) { + if o.LastPlannedFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastPlannedFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastPlannedFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastPlannedFailoverTime = &formatted +} + +func (o *RecoveryPlanProperties) GetLastTestFailoverTimeAsTime() (*time.Time, error) { + if o.LastTestFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastTestFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastTestFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastTestFailoverTime = &formatted +} + +func (o *RecoveryPlanProperties) GetLastUnplannedFailoverTimeAsTime() (*time.Time, error) { + if o.LastUnplannedFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUnplannedFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastUnplannedFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUnplannedFailoverTime = &formatted +} + +var _ json.Unmarshaler = &RecoveryPlanProperties{} + +func (s *RecoveryPlanProperties) UnmarshalJSON(bytes []byte) error { + type alias RecoveryPlanProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPlanProperties: %+v", err) + } + + s.AllowedOperations = decoded.AllowedOperations + s.CurrentScenario = decoded.CurrentScenario + s.CurrentScenarioStatus = decoded.CurrentScenarioStatus + s.CurrentScenarioStatusDescription = decoded.CurrentScenarioStatusDescription + s.FailoverDeploymentModel = decoded.FailoverDeploymentModel + s.FriendlyName = decoded.FriendlyName + s.Groups = decoded.Groups + s.LastPlannedFailoverTime = decoded.LastPlannedFailoverTime + s.LastTestFailoverTime = decoded.LastTestFailoverTime + s.LastUnplannedFailoverTime = decoded.LastUnplannedFailoverTime + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryFabricId = decoded.PrimaryFabricId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryFabricId = decoded.RecoveryFabricId + s.ReplicationProviders = decoded.ReplicationProviders + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificDetails, 0) + for i, val := range listTemp { + impl, err := unmarshalRecoveryPlanProviderSpecificDetailsImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go new file mode 100644 index 00000000000..e3d9c1e2cbf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go @@ -0,0 +1,9 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanProtectedItem struct { + Id *string `json:"id,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go new file mode 100644 index 00000000000..f3f72d62347 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go @@ -0,0 +1,53 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificDetails interface { +} + +// RawRecoveryPlanProviderSpecificDetailsImpl 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 RawRecoveryPlanProviderSpecificDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryPlanProviderSpecificDetailsImplementation(input []byte) (RecoveryPlanProviderSpecificDetails, 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 RecoveryPlanProviderSpecificDetails into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2ADetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2ADetails: %+v", err) + } + return out, nil + } + + out := RawRecoveryPlanProviderSpecificDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go new file mode 100644 index 00000000000..5edf059e80e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go @@ -0,0 +1,101 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificFailoverInput interface { +} + +// RawRecoveryPlanProviderSpecificFailoverInputImpl 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 RawRecoveryPlanProviderSpecificFailoverInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(input []byte) (RecoveryPlanProviderSpecificFailoverInput, 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 RecoveryPlanProviderSpecificFailoverInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2AFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2AFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzureFailback") { + var out RecoveryPlanHyperVReplicaAzureFailbackInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out RecoveryPlanHyperVReplicaAzureFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out RecoveryPlanInMageAzureV2FailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out RecoveryPlanInMageFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out RecoveryPlanInMageRcmFailbackFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out RecoveryPlanInMageRcmFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + return out, nil + } + + out := RawRecoveryPlanProviderSpecificFailoverInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go new file mode 100644 index 00000000000..b0870834d88 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go @@ -0,0 +1,53 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificInput interface { +} + +// RawRecoveryPlanProviderSpecificInputImpl 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 RawRecoveryPlanProviderSpecificInputImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryPlanProviderSpecificInputImplementation(input []byte) (RecoveryPlanProviderSpecificInput, 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 RecoveryPlanProviderSpecificInput into map[string]interface: %+v", err) + } + + value, ok := temp["instanceType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2AInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2AInput: %+v", err) + } + return out, nil + } + + out := RawRecoveryPlanProviderSpecificInputImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go new file mode 100644 index 00000000000..07855278c4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go @@ -0,0 +1,43 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanActionDetails = RecoveryPlanScriptActionDetails{} + +type RecoveryPlanScriptActionDetails struct { + FabricLocation RecoveryPlanActionLocation `json:"fabricLocation"` + Path string `json:"path"` + Timeout *string `json:"timeout,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails +} + +var _ json.Marshaler = RecoveryPlanScriptActionDetails{} + +func (s RecoveryPlanScriptActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanScriptActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanScriptActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanScriptActionDetails: %+v", err) + } + decoded["instanceType"] = "ScriptActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanScriptActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go new file mode 100644 index 00000000000..4379adce6cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverCleanupInput struct { + Properties RecoveryPlanTestFailoverCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go new file mode 100644 index 00000000000..2b3b65c28c3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go new file mode 100644 index 00000000000..c5706924b4e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverInput struct { + Properties RecoveryPlanTestFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go new file mode 100644 index 00000000000..76922b79ed1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go @@ -0,0 +1,53 @@ +package replicationrecoveryplans + +import ( + "encoding/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 RecoveryPlanTestFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType string `json:"networkType"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPlanTestFailoverInputProperties{} + +func (s *RecoveryPlanTestFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + type alias RecoveryPlanTestFailoverInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPlanTestFailoverInputProperties: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.NetworkId = decoded.NetworkId + s.NetworkType = decoded.NetworkType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanTestFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := unmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanTestFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go new file mode 100644 index 00000000000..92fc6578c58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanUnplannedFailoverInput struct { + Properties RecoveryPlanUnplannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go new file mode 100644 index 00000000000..a3337d470e6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +import ( + "encoding/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 RecoveryPlanUnplannedFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` + SourceSiteOperations SourceSiteOperations `json:"sourceSiteOperations"` +} + +var _ json.Unmarshaler = &RecoveryPlanUnplannedFailoverInputProperties{} + +func (s *RecoveryPlanUnplannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + type alias RecoveryPlanUnplannedFailoverInputProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPlanUnplannedFailoverInputProperties: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.SourceSiteOperations = decoded.SourceSiteOperations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanUnplannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := unmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanUnplannedFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_updaterecoveryplaninput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_updaterecoveryplaninput.go new file mode 100644 index 00000000000..f1611672eed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_updaterecoveryplaninput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateRecoveryPlanInput struct { + Properties *UpdateRecoveryPlanInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go new file mode 100644 index 00000000000..dba269e1ee5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateRecoveryPlanInputProperties struct { + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/predicates.go new file mode 100644 index 00000000000..d6c5e9c2534 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/predicates.go @@ -0,0 +1,32 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPlanOperationPredicate) Matches(input RecoveryPlan) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/version.go new file mode 100644 index 00000000000..70cd651b55c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryplans/version.go @@ -0,0 +1,12 @@ +package replicationrecoveryplans + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationrecoveryplans/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/README.md new file mode 100644 index 00000000000..c2a88627e04 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/README.md @@ -0,0 +1,123 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders` Documentation + +The `replicationrecoveryservicesproviders` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders" +``` + + +### Client Initialization + +```go +client := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Create` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationRecoveryServicesProviderValue") + +payload := replicationrecoveryservicesproviders.AddRecoveryServicesProviderInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Delete` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationRecoveryServicesProviderValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Get` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationRecoveryServicesProviderValue") + +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: `ReplicationRecoveryServicesProvidersClient.List` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Purge` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationRecoveryServicesProviderValue") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.RefreshProvider` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationRecoveryServicesProviderValue") + +if err := client.RefreshProviderThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/client.go new file mode 100644 index 00000000000..32fc26ccfb8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/client.go @@ -0,0 +1,26 @@ +package replicationrecoveryservicesproviders + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationRecoveryServicesProvidersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationRecoveryServicesProvidersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationRecoveryServicesProvidersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationrecoveryservicesproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationRecoveryServicesProvidersClient: %+v", err) + } + + return &ReplicationRecoveryServicesProvidersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/constants.go new file mode 100644 index 00000000000..1019dcf0757 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/constants.go @@ -0,0 +1,101 @@ +package replicationrecoveryservicesproviders + +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 AgentVersionStatus string + +const ( + AgentVersionStatusDeprecated AgentVersionStatus = "Deprecated" + AgentVersionStatusNotSupported AgentVersionStatus = "NotSupported" + AgentVersionStatusSecurityUpdateRequired AgentVersionStatus = "SecurityUpdateRequired" + AgentVersionStatusSupported AgentVersionStatus = "Supported" + AgentVersionStatusUpdateRequired AgentVersionStatus = "UpdateRequired" +) + +func PossibleValuesForAgentVersionStatus() []string { + return []string{ + string(AgentVersionStatusDeprecated), + string(AgentVersionStatusNotSupported), + string(AgentVersionStatusSecurityUpdateRequired), + string(AgentVersionStatusSupported), + string(AgentVersionStatusUpdateRequired), + } +} + +func (s *AgentVersionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentVersionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentVersionStatus(input string) (*AgentVersionStatus, error) { + vals := map[string]AgentVersionStatus{ + "deprecated": AgentVersionStatusDeprecated, + "notsupported": AgentVersionStatusNotSupported, + "securityupdaterequired": AgentVersionStatusSecurityUpdateRequired, + "supported": AgentVersionStatusSupported, + "updaterequired": AgentVersionStatusUpdateRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentVersionStatus(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationfabric.go new file mode 100644 index 00000000000..a3c20606a94 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationfabric.go @@ -0,0 +1,134 @@ +package replicationrecoveryservicesproviders + +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 = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go new file mode 100644 index 00000000000..e7060aeb35b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationrecoveryservicesproviders + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go new file mode 100644 index 00000000000..4dfca1a17a6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go @@ -0,0 +1,143 @@ +package replicationrecoveryservicesproviders + +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 = &ReplicationRecoveryServicesProviderId{} + +// ReplicationRecoveryServicesProviderId is a struct representing the Resource ID for a Replication Recovery Services Provider +type ReplicationRecoveryServicesProviderId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationRecoveryServicesProviderName string +} + +// NewReplicationRecoveryServicesProviderID returns a new ReplicationRecoveryServicesProviderId struct +func NewReplicationRecoveryServicesProviderID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationRecoveryServicesProviderName string) ReplicationRecoveryServicesProviderId { + return ReplicationRecoveryServicesProviderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationRecoveryServicesProviderName: replicationRecoveryServicesProviderName, + } +} + +// ParseReplicationRecoveryServicesProviderID parses 'input' into a ReplicationRecoveryServicesProviderId +func ParseReplicationRecoveryServicesProviderID(input string) (*ReplicationRecoveryServicesProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryServicesProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryServicesProviderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationRecoveryServicesProviderIDInsensitively parses 'input' case-insensitively into a ReplicationRecoveryServicesProviderId +// note: this method should only be used for API response data and not user input +func ParseReplicationRecoveryServicesProviderIDInsensitively(input string) (*ReplicationRecoveryServicesProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryServicesProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryServicesProviderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationRecoveryServicesProviderId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationRecoveryServicesProviderName, ok = input.Parsed["replicationRecoveryServicesProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationRecoveryServicesProviderName", input) + } + + return nil +} + +// ValidateReplicationRecoveryServicesProviderID checks that 'input' can be parsed as a Replication Recovery Services Provider ID +func ValidateReplicationRecoveryServicesProviderID(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 := ParseReplicationRecoveryServicesProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationRecoveryServicesProviders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationRecoveryServicesProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationRecoveryServicesProviders", "replicationRecoveryServicesProviders", "replicationRecoveryServicesProviders"), + resourceids.UserSpecifiedSegment("replicationRecoveryServicesProviderName", "replicationRecoveryServicesProviderValue"), + } +} + +// String returns a human-readable description of this Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Recovery Services Provider Name: %q", id.ReplicationRecoveryServicesProviderName), + } + return fmt.Sprintf("Replication Recovery Services Provider (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go new file mode 100644 index 00000000000..0b851d6e153 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go @@ -0,0 +1,372 @@ +package replicationrecoveryservicesproviders + +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 = &ReplicationRecoveryServicesProviderId{} + +func TestNewReplicationRecoveryServicesProviderID(t *testing.T) { + id := NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationRecoveryServicesProviderValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationRecoveryServicesProviderName != "replicationRecoveryServicesProviderValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationRecoveryServicesProviderName'", id.ReplicationRecoveryServicesProviderName, "replicationRecoveryServicesProviderValue") + } +} + +func TestFormatReplicationRecoveryServicesProviderID(t *testing.T) { + actual := NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationRecoveryServicesProviderValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationRecoveryServicesProviderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryServicesProviderId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationRecoveryServicesProviders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderValue", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationRecoveryServicesProviderName: "replicationRecoveryServicesProviderValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryServicesProviderID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationRecoveryServicesProviderName != v.Expected.ReplicationRecoveryServicesProviderName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryServicesProviderName", v.Expected.ReplicationRecoveryServicesProviderName, actual.ReplicationRecoveryServicesProviderName) + } + + } +} + +func TestParseReplicationRecoveryServicesProviderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryServicesProviderId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationRecoveryServicesProviders", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderValue", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationRecoveryServicesProviderName: "replicationRecoveryServicesProviderValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErVaLuE", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationRecoveryServicesProviderName: "rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryServicesProviderIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationRecoveryServicesProviderName != v.Expected.ReplicationRecoveryServicesProviderName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryServicesProviderName", v.Expected.ReplicationRecoveryServicesProviderName, actual.ReplicationRecoveryServicesProviderName) + } + + } +} + +func TestSegmentsForReplicationRecoveryServicesProviderId(t *testing.T) { + segments := ReplicationRecoveryServicesProviderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationRecoveryServicesProviderId 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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_vault.go new file mode 100644 index 00000000000..49b26fd17a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_vault.go @@ -0,0 +1,125 @@ +package replicationrecoveryservicesproviders + +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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_vault_test.go new file mode 100644 index 00000000000..a96cfcee93f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationrecoveryservicesproviders + +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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_create.go new file mode 100644 index 00000000000..d703662cb7a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_create.go @@ -0,0 +1,75 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryServicesProvider +} + +// Create ... +func (c ReplicationRecoveryServicesProvidersClient) Create(ctx context.Context, id ReplicationRecoveryServicesProviderId, input AddRecoveryServicesProviderInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) CreateThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId, input AddRecoveryServicesProviderInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_delete.go new file mode 100644 index 00000000000..d415ca70852 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_delete.go @@ -0,0 +1,70 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationRecoveryServicesProvidersClient) Delete(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) DeleteThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_get.go new file mode 100644 index 00000000000..2bb434d0ce4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_get.go @@ -0,0 +1,51 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryServicesProvider +} + +// Get ... +func (c ReplicationRecoveryServicesProvidersClient) Get(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_list.go new file mode 100644 index 00000000000..93d7257d8e2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_list.go @@ -0,0 +1,91 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryServicesProvider +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryServicesProvider +} + +// List ... +func (c ReplicationRecoveryServicesProvidersClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationRecoveryServicesProviders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecoveryServicesProvider `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationRecoveryServicesProvidersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RecoveryServicesProviderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryServicesProvidersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate RecoveryServicesProviderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RecoveryServicesProvider, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..d86ebc3e2f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go @@ -0,0 +1,91 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryServicesProvider +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryServicesProvider +} + +// ListByReplicationFabrics ... +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationRecoveryServicesProviders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecoveryServicesProvider `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, RecoveryServicesProviderOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate RecoveryServicesProviderOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]RecoveryServicesProvider, 0) + + resp, err := c.ListByReplicationFabrics(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_purge.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_purge.go new file mode 100644 index 00000000000..769e022934f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_purge.go @@ -0,0 +1,70 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationRecoveryServicesProvidersClient) Purge(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result PurgeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) PurgeThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_refreshprovider.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_refreshprovider.go new file mode 100644 index 00000000000..ccbc812c22a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/method_refreshprovider.go @@ -0,0 +1,71 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RefreshProviderOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryServicesProvider +} + +// RefreshProvider ... +func (c ReplicationRecoveryServicesProvidersClient) RefreshProvider(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result RefreshProviderOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshProvider", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RefreshProviderThenPoll performs RefreshProvider then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) RefreshProviderThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) error { + result, err := c.RefreshProvider(ctx, id) + if err != nil { + return fmt.Errorf("performing RefreshProvider: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RefreshProvider: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go new file mode 100644 index 00000000000..2c945e24875 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddRecoveryServicesProviderInput struct { + Properties AddRecoveryServicesProviderInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go new file mode 100644 index 00000000000..9562bac2653 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go @@ -0,0 +1,13 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddRecoveryServicesProviderInputProperties struct { + AuthenticationIdentityInput IdentityProviderInput `json:"authenticationIdentityInput"` + BiosId *string `json:"biosId,omitempty"` + DataPlaneAuthenticationIdentityInput *IdentityProviderInput `json:"dataPlaneAuthenticationIdentityInput,omitempty"` + MachineId *string `json:"machineId,omitempty"` + MachineName string `json:"machineName"` + ResourceAccessIdentityInput IdentityProviderInput `json:"resourceAccessIdentityInput"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_healtherror.go new file mode 100644 index 00000000000..b0c92df9ee5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationrecoveryservicesproviders + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go new file mode 100644 index 00000000000..ab5ea5efed4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderDetails struct { + AadAuthority *string `json:"aadAuthority,omitempty"` + ApplicationId *string `json:"applicationId,omitempty"` + Audience *string `json:"audience,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_identityproviderinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_identityproviderinput.go new file mode 100644 index 00000000000..df9e5c5085d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_identityproviderinput.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderInput struct { + AadAuthority string `json:"aadAuthority"` + ApplicationId string `json:"applicationId"` + Audience string `json:"audience"` + ObjectId string `json:"objectId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_innerhealtherror.go new file mode 100644 index 00000000000..3ef08acf21c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationrecoveryservicesproviders + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go new file mode 100644 index 00000000000..8b870a59529 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryServicesProvider struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryServicesProviderProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go new file mode 100644 index 00000000000..db54434b901 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go @@ -0,0 +1,57 @@ +package replicationrecoveryservicesproviders + +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 RecoveryServicesProviderProperties struct { + AllowedScenarios *[]string `json:"allowedScenarios,omitempty"` + AuthenticationIdentityDetails *IdentityProviderDetails `json:"authenticationIdentityDetails,omitempty"` + BiosId *string `json:"biosId,omitempty"` + ConnectionStatus *string `json:"connectionStatus,omitempty"` + DataPlaneAuthenticationIdentityDetails *IdentityProviderDetails `json:"dataPlaneAuthenticationIdentityDetails,omitempty"` + DraIdentifier *string `json:"draIdentifier,omitempty"` + FabricFriendlyName *string `json:"fabricFriendlyName,omitempty"` + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + LastHeartBeat *string `json:"lastHeartBeat,omitempty"` + MachineId *string `json:"machineId,omitempty"` + MachineName *string `json:"machineName,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProviderVersion *string `json:"providerVersion,omitempty"` + ProviderVersionDetails *VersionDetails `json:"providerVersionDetails,omitempty"` + ProviderVersionExpiryDate *string `json:"providerVersionExpiryDate,omitempty"` + ProviderVersionState *string `json:"providerVersionState,omitempty"` + ResourceAccessIdentityDetails *IdentityProviderDetails `json:"resourceAccessIdentityDetails,omitempty"` + ServerVersion *string `json:"serverVersion,omitempty"` +} + +func (o *RecoveryServicesProviderProperties) GetLastHeartBeatAsTime() (*time.Time, error) { + if o.LastHeartBeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartBeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryServicesProviderProperties) SetLastHeartBeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartBeat = &formatted +} + +func (o *RecoveryServicesProviderProperties) GetProviderVersionExpiryDateAsTime() (*time.Time, error) { + if o.ProviderVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ProviderVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryServicesProviderProperties) SetProviderVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ProviderVersionExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_versiondetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_versiondetails.go new file mode 100644 index 00000000000..9a441abb5ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/model_versiondetails.go @@ -0,0 +1,28 @@ +package replicationrecoveryservicesproviders + +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 VersionDetails struct { + ExpiryDate *string `json:"expiryDate,omitempty"` + Status *AgentVersionStatus `json:"status,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *VersionDetails) GetExpiryDateAsTime() (*time.Time, error) { + if o.ExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *VersionDetails) SetExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/predicates.go new file mode 100644 index 00000000000..4377b19a42f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/predicates.go @@ -0,0 +1,32 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryServicesProviderOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryServicesProviderOperationPredicate) Matches(input RecoveryServicesProvider) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/version.go new file mode 100644 index 00000000000..97913c62c2e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationrecoveryservicesproviders/version.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationrecoveryservicesproviders/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/README.md new file mode 100644 index 00000000000..4cbd15cde2a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings` Documentation + +The `replicationstorageclassificationmappings` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings" +``` + + +### Client Initialization + +```go +client := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue", "replicationStorageClassificationMappingValue") + +payload := replicationstorageclassificationmappings.StorageClassificationMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue", "replicationStorageClassificationMappingValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue", "replicationStorageClassificationMappingValue") + +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: `ReplicationStorageClassificationMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.ListByReplicationStorageClassifications` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue") + +// alternatively `client.ListByReplicationStorageClassifications(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationStorageClassificationsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/client.go new file mode 100644 index 00000000000..2bedc378cda --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/client.go @@ -0,0 +1,26 @@ +package replicationstorageclassificationmappings + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationStorageClassificationMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationStorageClassificationMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationStorageClassificationMappingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationstorageclassificationmappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationStorageClassificationMappingsClient: %+v", err) + } + + return &ReplicationStorageClassificationMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go new file mode 100644 index 00000000000..945a7193703 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go @@ -0,0 +1,143 @@ +package replicationstorageclassificationmappings + +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 = &ReplicationStorageClassificationId{} + +// ReplicationStorageClassificationId is a struct representing the Resource ID for a Replication Storage Classification +type ReplicationStorageClassificationId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string +} + +// NewReplicationStorageClassificationID returns a new ReplicationStorageClassificationId struct +func NewReplicationStorageClassificationID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string) ReplicationStorageClassificationId { + return ReplicationStorageClassificationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + } +} + +// ParseReplicationStorageClassificationID parses 'input' into a ReplicationStorageClassificationId +func ParseReplicationStorageClassificationID(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationIDInsensitively(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationID checks that 'input' can be parsed as a Replication Storage Classification ID +func ValidateReplicationStorageClassificationID(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 := ParseReplicationStorageClassificationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification ID +func (id ReplicationStorageClassificationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationValue"), + } +} + +// String returns a human-readable description of this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + } + return fmt.Sprintf("Replication Storage Classification (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go new file mode 100644 index 00000000000..1bccee9d1e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go @@ -0,0 +1,372 @@ +package replicationstorageclassificationmappings + +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 = &ReplicationStorageClassificationId{} + +func TestNewReplicationStorageClassificationID(t *testing.T) { + id := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationValue") + } +} + +func TestFormatReplicationStorageClassificationID(t *testing.T) { + actual := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationStorageClassificationName: "replicationStorageClassificationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestParseReplicationStorageClassificationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationStorageClassificationName: "replicationStorageClassificationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationId(t *testing.T) { + segments := ReplicationStorageClassificationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationId 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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go new file mode 100644 index 00000000000..dfc0e2ef2b1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go @@ -0,0 +1,152 @@ +package replicationstorageclassificationmappings + +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 = &ReplicationStorageClassificationMappingId{} + +// ReplicationStorageClassificationMappingId is a struct representing the Resource ID for a Replication Storage Classification Mapping +type ReplicationStorageClassificationMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string + ReplicationStorageClassificationMappingName string +} + +// NewReplicationStorageClassificationMappingID returns a new ReplicationStorageClassificationMappingId struct +func NewReplicationStorageClassificationMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string, replicationStorageClassificationMappingName string) ReplicationStorageClassificationMappingId { + return ReplicationStorageClassificationMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + ReplicationStorageClassificationMappingName: replicationStorageClassificationMappingName, + } +} + +// ParseReplicationStorageClassificationMappingID parses 'input' into a ReplicationStorageClassificationMappingId +func ParseReplicationStorageClassificationMappingID(input string) (*ReplicationStorageClassificationMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationMappingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationMappingIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationMappingIDInsensitively(input string) (*ReplicationStorageClassificationMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationMappingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationMappingId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + if id.ReplicationStorageClassificationMappingName, ok = input.Parsed["replicationStorageClassificationMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationMappingName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationMappingID checks that 'input' can be parsed as a Replication Storage Classification Mapping ID +func ValidateReplicationStorageClassificationMappingID(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 := ParseReplicationStorageClassificationMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s/replicationStorageClassificationMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName, id.ReplicationStorageClassificationMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationValue"), + resourceids.StaticSegment("staticReplicationStorageClassificationMappings", "replicationStorageClassificationMappings", "replicationStorageClassificationMappings"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationMappingName", "replicationStorageClassificationMappingValue"), + } +} + +// String returns a human-readable description of this Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + fmt.Sprintf("Replication Storage Classification Mapping Name: %q", id.ReplicationStorageClassificationMappingName), + } + return fmt.Sprintf("Replication Storage Classification Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go new file mode 100644 index 00000000000..d82238ca716 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go @@ -0,0 +1,417 @@ +package replicationstorageclassificationmappings + +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 = &ReplicationStorageClassificationMappingId{} + +func TestNewReplicationStorageClassificationMappingID(t *testing.T) { + id := NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue", "replicationStorageClassificationMappingValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationValue") + } + + if id.ReplicationStorageClassificationMappingName != "replicationStorageClassificationMappingValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationMappingName'", id.ReplicationStorageClassificationMappingName, "replicationStorageClassificationMappingValue") + } +} + +func TestFormatReplicationStorageClassificationMappingID(t *testing.T) { + actual := NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue", "replicationStorageClassificationMappingValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/replicationStorageClassificationMappings/replicationStorageClassificationMappingValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationMappingId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/replicationStorageClassificationMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/replicationStorageClassificationMappings/replicationStorageClassificationMappingValue", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationStorageClassificationName: "replicationStorageClassificationValue", + ReplicationStorageClassificationMappingName: "replicationStorageClassificationMappingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/replicationStorageClassificationMappings/replicationStorageClassificationMappingValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationMappingID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + if actual.ReplicationStorageClassificationMappingName != v.Expected.ReplicationStorageClassificationMappingName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationMappingName", v.Expected.ReplicationStorageClassificationMappingName, actual.ReplicationStorageClassificationMappingName) + } + + } +} + +func TestParseReplicationStorageClassificationMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationMappingId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/replicationStorageClassificationMappings", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/replicationStorageClassificationMappings/replicationStorageClassificationMappingValue", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationStorageClassificationName: "replicationStorageClassificationValue", + ReplicationStorageClassificationMappingName: "replicationStorageClassificationMappingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/replicationStorageClassificationMappings/replicationStorageClassificationMappingValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgVaLuE", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe", + ReplicationStorageClassificationMappingName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationMappingIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + if actual.ReplicationStorageClassificationMappingName != v.Expected.ReplicationStorageClassificationMappingName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationMappingName", v.Expected.ReplicationStorageClassificationMappingName, actual.ReplicationStorageClassificationMappingName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationMappingId(t *testing.T) { + segments := ReplicationStorageClassificationMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationMappingId 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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_vault.go new file mode 100644 index 00000000000..1a3e25a55f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_vault.go @@ -0,0 +1,125 @@ +package replicationstorageclassificationmappings + +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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_vault_test.go new file mode 100644 index 00000000000..d64669f0a1b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationstorageclassificationmappings + +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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_create.go new file mode 100644 index 00000000000..f295340750d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_create.go @@ -0,0 +1,75 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StorageClassificationMapping +} + +// Create ... +func (c ReplicationStorageClassificationMappingsClient) Create(ctx context.Context, id ReplicationStorageClassificationMappingId, input StorageClassificationMappingInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationStorageClassificationMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationStorageClassificationMappingId, input StorageClassificationMappingInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_delete.go new file mode 100644 index 00000000000..cced683f6b0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_delete.go @@ -0,0 +1,70 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationStorageClassificationMappingsClient) Delete(ctx context.Context, id ReplicationStorageClassificationMappingId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationStorageClassificationMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationStorageClassificationMappingId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_get.go new file mode 100644 index 00000000000..1b9b1dfffb9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_get.go @@ -0,0 +1,51 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StorageClassificationMapping +} + +// Get ... +func (c ReplicationStorageClassificationMappingsClient) Get(ctx context.Context, id ReplicationStorageClassificationMappingId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_list.go new file mode 100644 index 00000000000..8696f5f4962 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_list.go @@ -0,0 +1,91 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassificationMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassificationMapping +} + +// List ... +func (c ReplicationStorageClassificationMappingsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationStorageClassificationMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageClassificationMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StorageClassificationMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate StorageClassificationMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StorageClassificationMapping, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go new file mode 100644 index 00000000000..6ca422fbaf0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go @@ -0,0 +1,91 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationStorageClassificationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassificationMapping +} + +type ListByReplicationStorageClassificationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassificationMapping +} + +// ListByReplicationStorageClassifications ... +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassifications(ctx context.Context, id ReplicationStorageClassificationId) (result ListByReplicationStorageClassificationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationStorageClassificationMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageClassificationMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationStorageClassificationsComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsComplete(ctx context.Context, id ReplicationStorageClassificationId) (ListByReplicationStorageClassificationsCompleteResult, error) { + return c.ListByReplicationStorageClassificationsCompleteMatchingPredicate(ctx, id, StorageClassificationMappingOperationPredicate{}) +} + +// ListByReplicationStorageClassificationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsCompleteMatchingPredicate(ctx context.Context, id ReplicationStorageClassificationId, predicate StorageClassificationMappingOperationPredicate) (result ListByReplicationStorageClassificationsCompleteResult, err error) { + items := make([]StorageClassificationMapping, 0) + + resp, err := c.ListByReplicationStorageClassifications(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationStorageClassificationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go new file mode 100644 index 00000000000..70642e74bca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go @@ -0,0 +1,12 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageClassificationMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go new file mode 100644 index 00000000000..158940ea210 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingInput struct { + Properties *StorageMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go new file mode 100644 index 00000000000..0b0d8c58bea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingProperties struct { + TargetStorageClassificationId *string `json:"targetStorageClassificationId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go new file mode 100644 index 00000000000..7dc80064316 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMappingInputProperties struct { + TargetStorageClassificationId *string `json:"targetStorageClassificationId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/predicates.go new file mode 100644 index 00000000000..128f8cd8e3d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/predicates.go @@ -0,0 +1,32 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageClassificationMappingOperationPredicate) Matches(input StorageClassificationMapping) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/version.go new file mode 100644 index 00000000000..6a669cb315a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassificationmappings/version.go @@ -0,0 +1,12 @@ +package replicationstorageclassificationmappings + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationstorageclassificationmappings/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/README.md new file mode 100644 index 00000000000..cfc9af0d607 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications` Documentation + +The `replicationstorageclassifications` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications" +``` + + +### Client Initialization + +```go +client := replicationstorageclassifications.NewReplicationStorageClassificationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationStorageClassificationsClient.Get` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue") + +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: `ReplicationStorageClassificationsClient.List` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationStorageClassificationsClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/client.go new file mode 100644 index 00000000000..074e60a52aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/client.go @@ -0,0 +1,26 @@ +package replicationstorageclassifications + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationStorageClassificationsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationStorageClassificationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationStorageClassificationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationstorageclassifications", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationStorageClassificationsClient: %+v", err) + } + + return &ReplicationStorageClassificationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationfabric.go new file mode 100644 index 00000000000..5862912c8c4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationfabric.go @@ -0,0 +1,134 @@ +package replicationstorageclassifications + +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 = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationfabric_test.go new file mode 100644 index 00000000000..7aab0b3590a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationstorageclassifications + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationstorageclassification.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationstorageclassification.go new file mode 100644 index 00000000000..131299fb728 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationstorageclassification.go @@ -0,0 +1,143 @@ +package replicationstorageclassifications + +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 = &ReplicationStorageClassificationId{} + +// ReplicationStorageClassificationId is a struct representing the Resource ID for a Replication Storage Classification +type ReplicationStorageClassificationId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string +} + +// NewReplicationStorageClassificationID returns a new ReplicationStorageClassificationId struct +func NewReplicationStorageClassificationID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string) ReplicationStorageClassificationId { + return ReplicationStorageClassificationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + } +} + +// ParseReplicationStorageClassificationID parses 'input' into a ReplicationStorageClassificationId +func ParseReplicationStorageClassificationID(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationIDInsensitively(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationID checks that 'input' can be parsed as a Replication Storage Classification ID +func ValidateReplicationStorageClassificationID(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 := ParseReplicationStorageClassificationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification ID +func (id ReplicationStorageClassificationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationValue"), + } +} + +// String returns a human-readable description of this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + } + return fmt.Sprintf("Replication Storage Classification (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationstorageclassification_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationstorageclassification_test.go new file mode 100644 index 00000000000..8bdaa6b9f9c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_replicationstorageclassification_test.go @@ -0,0 +1,372 @@ +package replicationstorageclassifications + +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 = &ReplicationStorageClassificationId{} + +func TestNewReplicationStorageClassificationID(t *testing.T) { + id := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationValue") + } +} + +func TestFormatReplicationStorageClassificationID(t *testing.T) { + actual := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationStorageClassificationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationStorageClassificationName: "replicationStorageClassificationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestParseReplicationStorageClassificationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationStorageClassificationName: "replicationStorageClassificationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationStorageClassifications/replicationStorageClassificationValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationId(t *testing.T) { + segments := ReplicationStorageClassificationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationId 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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_vault.go new file mode 100644 index 00000000000..25870025301 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_vault.go @@ -0,0 +1,125 @@ +package replicationstorageclassifications + +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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_vault_test.go new file mode 100644 index 00000000000..a3520dd160d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationstorageclassifications + +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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_get.go new file mode 100644 index 00000000000..94e8a48ab9e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_get.go @@ -0,0 +1,51 @@ +package replicationstorageclassifications + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StorageClassification +} + +// Get ... +func (c ReplicationStorageClassificationsClient) Get(ctx context.Context, id ReplicationStorageClassificationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_list.go new file mode 100644 index 00000000000..585ecfdd12d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_list.go @@ -0,0 +1,91 @@ +package replicationstorageclassifications + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassification +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassification +} + +// List ... +func (c ReplicationStorageClassificationsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationStorageClassifications", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageClassification `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StorageClassificationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate StorageClassificationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StorageClassification, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..9432d2c9d9d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/method_listbyreplicationfabrics.go @@ -0,0 +1,91 @@ +package replicationstorageclassifications + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassification +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassification +} + +// ListByReplicationFabrics ... +func (c ReplicationStorageClassificationsClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationStorageClassifications", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageClassification `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationsClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, StorageClassificationOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationsClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate StorageClassificationOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]StorageClassification, 0) + + resp, err := c.ListByReplicationFabrics(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/model_storageclassification.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/model_storageclassification.go new file mode 100644 index 00000000000..dfe018bfb1c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/model_storageclassification.go @@ -0,0 +1,12 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassification struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageClassificationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/model_storageclassificationproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/model_storageclassificationproperties.go new file mode 100644 index 00000000000..1d077061afd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/model_storageclassificationproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/predicates.go new file mode 100644 index 00000000000..6fae7a2f37c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/predicates.go @@ -0,0 +1,32 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageClassificationOperationPredicate) Matches(input StorageClassification) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/version.go new file mode 100644 index 00000000000..c08882652f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationstorageclassifications/version.go @@ -0,0 +1,12 @@ +package replicationstorageclassifications + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationstorageclassifications/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/README.md new file mode 100644 index 00000000000..f9f0d28b491 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/README.md @@ -0,0 +1,48 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth` Documentation + +The `replicationvaulthealth` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth" +``` + + +### Client Initialization + +```go +client := replicationvaulthealth.NewReplicationVaultHealthClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationVaultHealthClient.Get` + +```go +ctx := context.TODO() +id := replicationvaulthealth.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: `ReplicationVaultHealthClient.Refresh` + +```go +ctx := context.TODO() +id := replicationvaulthealth.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +if err := client.RefreshThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/client.go new file mode 100644 index 00000000000..4f2d2fd7b2f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/client.go @@ -0,0 +1,26 @@ +package replicationvaulthealth + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationVaultHealthClient struct { + Client *resourcemanager.Client +} + +func NewReplicationVaultHealthClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationVaultHealthClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationvaulthealth", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationVaultHealthClient: %+v", err) + } + + return &ReplicationVaultHealthClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/constants.go new file mode 100644 index 00000000000..037b2d3c9ae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/constants.go @@ -0,0 +1,166 @@ +package replicationvaulthealth + +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 HealthErrorCategory string + +const ( + HealthErrorCategoryAgentAutoUpdateArtifactDeleted HealthErrorCategory = "AgentAutoUpdateArtifactDeleted" + HealthErrorCategoryAgentAutoUpdateInfra HealthErrorCategory = "AgentAutoUpdateInfra" + HealthErrorCategoryAgentAutoUpdateRunAsAccount HealthErrorCategory = "AgentAutoUpdateRunAsAccount" + HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired HealthErrorCategory = "AgentAutoUpdateRunAsAccountExpired" + HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry HealthErrorCategory = "AgentAutoUpdateRunAsAccountExpiry" + HealthErrorCategoryConfiguration HealthErrorCategory = "Configuration" + HealthErrorCategoryFabricInfrastructure HealthErrorCategory = "FabricInfrastructure" + HealthErrorCategoryNone HealthErrorCategory = "None" + HealthErrorCategoryReplication HealthErrorCategory = "Replication" + HealthErrorCategoryTestFailover HealthErrorCategory = "TestFailover" + HealthErrorCategoryVersionExpiry HealthErrorCategory = "VersionExpiry" +) + +func PossibleValuesForHealthErrorCategory() []string { + return []string{ + string(HealthErrorCategoryAgentAutoUpdateArtifactDeleted), + string(HealthErrorCategoryAgentAutoUpdateInfra), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccount), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry), + string(HealthErrorCategoryConfiguration), + string(HealthErrorCategoryFabricInfrastructure), + string(HealthErrorCategoryNone), + string(HealthErrorCategoryReplication), + string(HealthErrorCategoryTestFailover), + string(HealthErrorCategoryVersionExpiry), + } +} + +func (s *HealthErrorCategory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCategory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCategory(input string) (*HealthErrorCategory, error) { + vals := map[string]HealthErrorCategory{ + "agentautoupdateartifactdeleted": HealthErrorCategoryAgentAutoUpdateArtifactDeleted, + "agentautoupdateinfra": HealthErrorCategoryAgentAutoUpdateInfra, + "agentautoupdaterunasaccount": HealthErrorCategoryAgentAutoUpdateRunAsAccount, + "agentautoupdaterunasaccountexpired": HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired, + "agentautoupdaterunasaccountexpiry": HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry, + "configuration": HealthErrorCategoryConfiguration, + "fabricinfrastructure": HealthErrorCategoryFabricInfrastructure, + "none": HealthErrorCategoryNone, + "replication": HealthErrorCategoryReplication, + "testfailover": HealthErrorCategoryTestFailover, + "versionexpiry": HealthErrorCategoryVersionExpiry, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCategory(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type Severity string + +const ( + SeverityError Severity = "Error" + SeverityInfo Severity = "Info" + SeverityNONE Severity = "NONE" + SeverityWarning Severity = "Warning" +) + +func PossibleValuesForSeverity() []string { + return []string{ + string(SeverityError), + string(SeverityInfo), + string(SeverityNONE), + string(SeverityWarning), + } +} + +func (s *Severity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeverity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSeverity(input string) (*Severity, error) { + vals := map[string]Severity{ + "error": SeverityError, + "info": SeverityInfo, + "none": SeverityNONE, + "warning": SeverityWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Severity(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/id_vault.go new file mode 100644 index 00000000000..df7577bf0d1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/id_vault.go @@ -0,0 +1,125 @@ +package replicationvaulthealth + +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/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/id_vault_test.go new file mode 100644 index 00000000000..09b6acdc748 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvaulthealth + +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/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/method_get.go new file mode 100644 index 00000000000..64f1cb6f07f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/method_get.go @@ -0,0 +1,52 @@ +package replicationvaulthealth + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultHealthDetails +} + +// Get ... +func (c ReplicationVaultHealthClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationVaultHealth", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/method_refresh.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/method_refresh.go new file mode 100644 index 00000000000..17fd7e306a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/method_refresh.go @@ -0,0 +1,71 @@ +package replicationvaulthealth + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RefreshOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VaultHealthDetails +} + +// Refresh ... +func (c ReplicationVaultHealthClient) Refresh(ctx context.Context, id VaultId) (result RefreshOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/replicationVaultHealth/default/refresh", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RefreshThenPoll performs Refresh then polls until it's completed +func (c ReplicationVaultHealthClient) RefreshThenPoll(ctx context.Context, id VaultId) error { + result, err := c.Refresh(ctx, id) + if err != nil { + return fmt.Errorf("performing Refresh: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Refresh: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_healtherror.go new file mode 100644 index 00000000000..a1cded61cd6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationvaulthealth + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_healtherrorsummary.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_healtherrorsummary.go new file mode 100644 index 00000000000..7a99b52ddd8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_healtherrorsummary.go @@ -0,0 +1,14 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HealthErrorSummary struct { + AffectedResourceCorrelationIds *[]string `json:"affectedResourceCorrelationIds,omitempty"` + AffectedResourceSubtype *string `json:"affectedResourceSubtype,omitempty"` + AffectedResourceType *string `json:"affectedResourceType,omitempty"` + Category *HealthErrorCategory `json:"category,omitempty"` + Severity *Severity `json:"severity,omitempty"` + SummaryCode *string `json:"summaryCode,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_innerhealtherror.go new file mode 100644 index 00000000000..f01babb170f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationvaulthealth + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_resourcehealthsummary.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_resourcehealthsummary.go new file mode 100644 index 00000000000..6238fa00867 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_resourcehealthsummary.go @@ -0,0 +1,10 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthSummary struct { + CategorizedResourceCounts *map[string]int64 `json:"categorizedResourceCounts,omitempty"` + Issues *[]HealthErrorSummary `json:"issues,omitempty"` + ResourceCount *int64 `json:"resourceCount,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_vaulthealthdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_vaulthealthdetails.go new file mode 100644 index 00000000000..2c0736a7902 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_vaulthealthdetails.go @@ -0,0 +1,12 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultHealthDetails struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultHealthProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_vaulthealthproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_vaulthealthproperties.go new file mode 100644 index 00000000000..d17dd6d82bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/model_vaulthealthproperties.go @@ -0,0 +1,11 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultHealthProperties struct { + ContainersHealth *ResourceHealthSummary `json:"containersHealth,omitempty"` + FabricsHealth *ResourceHealthSummary `json:"fabricsHealth,omitempty"` + ProtectedItemsHealth *ResourceHealthSummary `json:"protectedItemsHealth,omitempty"` + VaultErrors *[]HealthError `json:"vaultErrors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/version.go new file mode 100644 index 00000000000..e02726ee64e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaulthealth/version.go @@ -0,0 +1,12 @@ +package replicationvaulthealth + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationvaulthealth/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/README.md new file mode 100644 index 00000000000..4780830ccd5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting` Documentation + +The `replicationvaultsetting` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting" +``` + + +### Client Initialization + +```go +client := replicationvaultsetting.NewReplicationVaultSettingClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationVaultSettingClient.Create` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationVaultSettingValue") + +payload := replicationvaultsetting.VaultSettingCreationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationVaultSettingClient.Get` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationVaultSettingValue") + +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: `ReplicationVaultSettingClient.List` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/client.go new file mode 100644 index 00000000000..bf3a8d86c8d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/client.go @@ -0,0 +1,26 @@ +package replicationvaultsetting + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationVaultSettingClient struct { + Client *resourcemanager.Client +} + +func NewReplicationVaultSettingClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationVaultSettingClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationvaultsetting", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationVaultSettingClient: %+v", err) + } + + return &ReplicationVaultSettingClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_replicationvaultsetting.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_replicationvaultsetting.go new file mode 100644 index 00000000000..e6309e04a35 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_replicationvaultsetting.go @@ -0,0 +1,134 @@ +package replicationvaultsetting + +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 = &ReplicationVaultSettingId{} + +// ReplicationVaultSettingId is a struct representing the Resource ID for a Replication Vault Setting +type ReplicationVaultSettingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationVaultSettingName string +} + +// NewReplicationVaultSettingID returns a new ReplicationVaultSettingId struct +func NewReplicationVaultSettingID(subscriptionId string, resourceGroupName string, vaultName string, replicationVaultSettingName string) ReplicationVaultSettingId { + return ReplicationVaultSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationVaultSettingName: replicationVaultSettingName, + } +} + +// ParseReplicationVaultSettingID parses 'input' into a ReplicationVaultSettingId +func ParseReplicationVaultSettingID(input string) (*ReplicationVaultSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationVaultSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationVaultSettingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationVaultSettingIDInsensitively parses 'input' case-insensitively into a ReplicationVaultSettingId +// note: this method should only be used for API response data and not user input +func ParseReplicationVaultSettingIDInsensitively(input string) (*ReplicationVaultSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationVaultSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationVaultSettingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationVaultSettingId) 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.ReplicationVaultSettingName, ok = input.Parsed["replicationVaultSettingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationVaultSettingName", input) + } + + return nil +} + +// ValidateReplicationVaultSettingID checks that 'input' can be parsed as a Replication Vault Setting ID +func ValidateReplicationVaultSettingID(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 := ParseReplicationVaultSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Vault Setting ID +func (id ReplicationVaultSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationVaultSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationVaultSettingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Vault Setting ID +func (id ReplicationVaultSettingId) 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("staticReplicationVaultSettings", "replicationVaultSettings", "replicationVaultSettings"), + resourceids.UserSpecifiedSegment("replicationVaultSettingName", "replicationVaultSettingValue"), + } +} + +// String returns a human-readable description of this Replication Vault Setting ID +func (id ReplicationVaultSettingId) 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("Replication Vault Setting Name: %q", id.ReplicationVaultSettingName), + } + return fmt.Sprintf("Replication Vault Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_replicationvaultsetting_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_replicationvaultsetting_test.go new file mode 100644 index 00000000000..a9594ceb9a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_replicationvaultsetting_test.go @@ -0,0 +1,327 @@ +package replicationvaultsetting + +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 = &ReplicationVaultSettingId{} + +func TestNewReplicationVaultSettingID(t *testing.T) { + id := NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationVaultSettingValue") + + 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.ReplicationVaultSettingName != "replicationVaultSettingValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationVaultSettingName'", id.ReplicationVaultSettingName, "replicationVaultSettingValue") + } +} + +func TestFormatReplicationVaultSettingID(t *testing.T) { + actual := NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationVaultSettingValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationVaultSettings/replicationVaultSettingValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationVaultSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationVaultSettingId + }{ + { + // 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/replicationVaultSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationVaultSettings/replicationVaultSettingValue", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationVaultSettingName: "replicationVaultSettingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationVaultSettings/replicationVaultSettingValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationVaultSettingID(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.ReplicationVaultSettingName != v.Expected.ReplicationVaultSettingName { + t.Fatalf("Expected %q but got %q for ReplicationVaultSettingName", v.Expected.ReplicationVaultSettingName, actual.ReplicationVaultSettingName) + } + + } +} + +func TestParseReplicationVaultSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationVaultSettingId + }{ + { + // 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/replicationVaultSettings", + Error: 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/rEpLiCaTiOnVaUlTsEtTiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationVaultSettings/replicationVaultSettingValue", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationVaultSettingName: "replicationVaultSettingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationVaultSettings/replicationVaultSettingValue/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/rEpLiCaTiOnVaUlTsEtTiNgS/rEpLiCaTiOnVaUlTsEtTiNgVaLuE", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationVaultSettingName: "rEpLiCaTiOnVaUlTsEtTiNgVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnVaUlTsEtTiNgS/rEpLiCaTiOnVaUlTsEtTiNgVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationVaultSettingIDInsensitively(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.ReplicationVaultSettingName != v.Expected.ReplicationVaultSettingName { + t.Fatalf("Expected %q but got %q for ReplicationVaultSettingName", v.Expected.ReplicationVaultSettingName, actual.ReplicationVaultSettingName) + } + + } +} + +func TestSegmentsForReplicationVaultSettingId(t *testing.T) { + segments := ReplicationVaultSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationVaultSettingId 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/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_vault.go new file mode 100644 index 00000000000..631dae67b06 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_vault.go @@ -0,0 +1,125 @@ +package replicationvaultsetting + +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/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_vault_test.go new file mode 100644 index 00000000000..956fddd1555 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvaultsetting + +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/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_create.go new file mode 100644 index 00000000000..2207eda514a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_create.go @@ -0,0 +1,74 @@ +package replicationvaultsetting + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VaultSetting +} + +// Create ... +func (c ReplicationVaultSettingClient) Create(ctx context.Context, id ReplicationVaultSettingId, input VaultSettingCreationInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationVaultSettingClient) CreateThenPoll(ctx context.Context, id ReplicationVaultSettingId, input VaultSettingCreationInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_get.go new file mode 100644 index 00000000000..296003d01b7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_get.go @@ -0,0 +1,51 @@ +package replicationvaultsetting + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultSetting +} + +// Get ... +func (c ReplicationVaultSettingClient) Get(ctx context.Context, id ReplicationVaultSettingId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_list.go new file mode 100644 index 00000000000..82d86747c89 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/method_list.go @@ -0,0 +1,91 @@ +package replicationvaultsetting + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VaultSetting +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VaultSetting +} + +// List ... +func (c ReplicationVaultSettingClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationVaultSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VaultSetting `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationVaultSettingClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VaultSettingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationVaultSettingClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate VaultSettingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VaultSetting, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsetting.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsetting.go new file mode 100644 index 00000000000..da949586ad3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsetting.go @@ -0,0 +1,12 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSetting struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultSettingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingcreationinput.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingcreationinput.go new file mode 100644 index 00000000000..ea6dddb61aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingcreationinput.go @@ -0,0 +1,8 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingCreationInput struct { + Properties VaultSettingCreationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go new file mode 100644 index 00000000000..d7654ac5546 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go @@ -0,0 +1,9 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingCreationInputProperties struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + VMwareToAzureProviderType *string `json:"vmwareToAzureProviderType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingproperties.go new file mode 100644 index 00000000000..c90471f30f5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/model_vaultsettingproperties.go @@ -0,0 +1,9 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingProperties struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + VMwareToAzureProviderType *string `json:"vmwareToAzureProviderType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/predicates.go new file mode 100644 index 00000000000..8e5065553c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/predicates.go @@ -0,0 +1,32 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VaultSettingOperationPredicate) Matches(input VaultSetting) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/version.go new file mode 100644 index 00000000000..a52efa7602f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvaultsetting/version.go @@ -0,0 +1,12 @@ +package replicationvaultsetting + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationvaultsetting/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/README.md new file mode 100644 index 00000000000..63dc3205fe9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters` Documentation + +The `replicationvcenters` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/replicationvcenters" +``` + + +### Client Initialization + +```go +client := replicationvcenters.NewReplicationvCentersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationvCentersClient.Create` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationvCenterValue") + +payload := replicationvcenters.AddVCenterRequest{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationvCentersClient.Delete` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationvCenterValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationvCentersClient.Get` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationvCenterValue") + +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: `ReplicationvCentersClient.List` + +```go +ctx := context.TODO() +id := replicationvcenters.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationvCentersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationvCentersClient.Update` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationvCenterValue") + +payload := replicationvcenters.UpdateVCenterRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/client.go new file mode 100644 index 00000000000..27cc23e985f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/client.go @@ -0,0 +1,26 @@ +package replicationvcenters + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationvCentersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationvCentersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationvCentersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationvcenters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationvCentersClient: %+v", err) + } + + return &ReplicationvCentersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/constants.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/constants.go new file mode 100644 index 00000000000..5eb916fd9d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/constants.go @@ -0,0 +1,51 @@ +package replicationvcenters + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationfabric.go new file mode 100644 index 00000000000..0616a886bd3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationfabric.go @@ -0,0 +1,134 @@ +package replicationvcenters + +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 = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationfabric_test.go new file mode 100644 index 00000000000..be8766fde5d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationvcenters + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationvcenter.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationvcenter.go new file mode 100644 index 00000000000..498218391f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationvcenter.go @@ -0,0 +1,143 @@ +package replicationvcenters + +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 = &ReplicationvCenterId{} + +// ReplicationvCenterId is a struct representing the Resource ID for a Replicationv Center +type ReplicationvCenterId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationvCenterName string +} + +// NewReplicationvCenterID returns a new ReplicationvCenterId struct +func NewReplicationvCenterID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationvCenterName string) ReplicationvCenterId { + return ReplicationvCenterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationvCenterName: replicationvCenterName, + } +} + +// ParseReplicationvCenterID parses 'input' into a ReplicationvCenterId +func ParseReplicationvCenterID(input string) (*ReplicationvCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationvCenterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationvCenterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationvCenterIDInsensitively parses 'input' case-insensitively into a ReplicationvCenterId +// note: this method should only be used for API response data and not user input +func ParseReplicationvCenterIDInsensitively(input string) (*ReplicationvCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationvCenterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationvCenterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationvCenterId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationvCenterName, ok = input.Parsed["replicationvCenterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationvCenterName", input) + } + + return nil +} + +// ValidateReplicationvCenterID checks that 'input' can be parsed as a Replicationv Center ID +func ValidateReplicationvCenterID(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 := ParseReplicationvCenterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replicationv Center ID +func (id ReplicationvCenterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationvCenters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationvCenterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replicationv Center ID +func (id ReplicationvCenterId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationvCenters", "replicationvCenters", "replicationvCenters"), + resourceids.UserSpecifiedSegment("replicationvCenterName", "replicationvCenterValue"), + } +} + +// String returns a human-readable description of this Replicationv Center ID +func (id ReplicationvCenterId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replicationv Center Name: %q", id.ReplicationvCenterName), + } + return fmt.Sprintf("Replicationv Center (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationvcenter_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationvcenter_test.go new file mode 100644 index 00000000000..75948ac5b87 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_replicationvcenter_test.go @@ -0,0 +1,372 @@ +package replicationvcenters + +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 = &ReplicationvCenterId{} + +func TestNewReplicationvCenterID(t *testing.T) { + id := NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationvCenterValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationvCenterName != "replicationvCenterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationvCenterName'", id.ReplicationvCenterName, "replicationvCenterValue") + } +} + +func TestFormatReplicationvCenterID(t *testing.T) { + actual := NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationvCenterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationvCenters/replicationvCenterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationvCenterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationvCenterId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationvCenters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationvCenters/replicationvCenterValue", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationvCenterName: "replicationvCenterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationvCenters/replicationvCenterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationvCenterID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationvCenterName != v.Expected.ReplicationvCenterName { + t.Fatalf("Expected %q but got %q for ReplicationvCenterName", v.Expected.ReplicationvCenterName, actual.ReplicationvCenterName) + } + + } +} + +func TestParseReplicationvCenterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationvCenterId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationvCenters", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnVcEnTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationvCenters/replicationvCenterValue", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationvCenterName: "replicationvCenterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationvCenters/replicationvCenterValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnVcEnTeRs/rEpLiCaTiOnVcEnTeRvAlUe", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationvCenterName: "rEpLiCaTiOnVcEnTeRvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnVcEnTeRs/rEpLiCaTiOnVcEnTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationvCenterIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationvCenterName != v.Expected.ReplicationvCenterName { + t.Fatalf("Expected %q but got %q for ReplicationvCenterName", v.Expected.ReplicationvCenterName, actual.ReplicationvCenterName) + } + + } +} + +func TestSegmentsForReplicationvCenterId(t *testing.T) { + segments := ReplicationvCenterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationvCenterId 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/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_vault.go new file mode 100644 index 00000000000..45e2f085eb3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_vault.go @@ -0,0 +1,125 @@ +package replicationvcenters + +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/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_vault_test.go new file mode 100644 index 00000000000..e3ecb481b34 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvcenters + +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/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_create.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_create.go new file mode 100644 index 00000000000..b08a9b622c7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_create.go @@ -0,0 +1,75 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VCenter +} + +// Create ... +func (c ReplicationvCentersClient) Create(ctx context.Context, id ReplicationvCenterId, input AddVCenterRequest) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationvCentersClient) CreateThenPoll(ctx context.Context, id ReplicationvCenterId, input AddVCenterRequest) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_delete.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_delete.go new file mode 100644 index 00000000000..67f5d8e7a5d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_delete.go @@ -0,0 +1,70 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReplicationvCentersClient) Delete(ctx context.Context, id ReplicationvCenterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationvCentersClient) DeleteThenPoll(ctx context.Context, id ReplicationvCenterId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_get.go new file mode 100644 index 00000000000..dce9c1ce397 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_get.go @@ -0,0 +1,51 @@ +package replicationvcenters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VCenter +} + +// Get ... +func (c ReplicationvCentersClient) Get(ctx context.Context, id ReplicationvCenterId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_list.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_list.go new file mode 100644 index 00000000000..54c2f2f8118 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_list.go @@ -0,0 +1,91 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VCenter +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VCenter +} + +// List ... +func (c ReplicationvCentersClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationvCenters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VCenter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationvCentersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VCenterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationvCentersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate VCenterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VCenter, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..f028b9e3fbd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_listbyreplicationfabrics.go @@ -0,0 +1,91 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VCenter +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []VCenter +} + +// ListByReplicationFabrics ... +func (c ReplicationvCentersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationvCenters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VCenter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationvCentersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, VCenterOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationvCentersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate VCenterOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]VCenter, 0) + + resp, err := c.ListByReplicationFabrics(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_update.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_update.go new file mode 100644 index 00000000000..8b93d0669a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/method_update.go @@ -0,0 +1,75 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VCenter +} + +// Update ... +func (c ReplicationvCentersClient) Update(ctx context.Context, id ReplicationvCenterId, input UpdateVCenterRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ReplicationvCentersClient) UpdateThenPoll(ctx context.Context, id ReplicationvCenterId, input UpdateVCenterRequest) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_addvcenterrequest.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_addvcenterrequest.go new file mode 100644 index 00000000000..8bc14e86c5c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_addvcenterrequest.go @@ -0,0 +1,8 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddVCenterRequest struct { + Properties *AddVCenterRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_addvcenterrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_addvcenterrequestproperties.go new file mode 100644 index 00000000000..3904def79d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_addvcenterrequestproperties.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddVCenterRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_healtherror.go new file mode 100644 index 00000000000..915bd6578cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationvcenters + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_innerhealtherror.go new file mode 100644 index 00000000000..5ed6fc2fe05 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationvcenters + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_updatevcenterrequest.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_updatevcenterrequest.go new file mode 100644 index 00000000000..c9ab295622d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_updatevcenterrequest.go @@ -0,0 +1,8 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVCenterRequest struct { + Properties *UpdateVCenterRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_updatevcenterrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_updatevcenterrequestproperties.go new file mode 100644 index 00000000000..9c02f563369 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_updatevcenterrequestproperties.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVCenterRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_vcenter.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_vcenter.go new file mode 100644 index 00000000000..5f8c2b26c1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_vcenter.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VCenter struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VCenterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_vcenterproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_vcenterproperties.go new file mode 100644 index 00000000000..9f4d3394f62 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/model_vcenterproperties.go @@ -0,0 +1,36 @@ +package replicationvcenters + +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 VCenterProperties struct { + DiscoveryStatus *string `json:"discoveryStatus,omitempty"` + FabricArmResourceName *string `json:"fabricArmResourceName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureId *string `json:"infrastructureId,omitempty"` + InternalId *string `json:"internalId,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} + +func (o *VCenterProperties) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *VCenterProperties) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/predicates.go new file mode 100644 index 00000000000..604db32ccd0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/predicates.go @@ -0,0 +1,32 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VCenterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VCenterOperationPredicate) Matches(input VCenter) bool { + + 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/recoveryservicessiterecovery/2023-08-01/replicationvcenters/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/version.go new file mode 100644 index 00000000000..2c7e2c7d0e1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/replicationvcenters/version.go @@ -0,0 +1,12 @@ +package replicationvcenters + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationvcenters/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/README.md new file mode 100644 index 00000000000..2887797d00c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems` Documentation + +The `supportedoperatingsystems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems" +``` + + +### Client Initialization + +```go +client := supportedoperatingsystems.NewSupportedOperatingSystemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SupportedOperatingSystemsClient.Get` + +```go +ctx := context.TODO() +id := supportedoperatingsystems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +read, err := client.Get(ctx, id, supportedoperatingsystems.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/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/client.go new file mode 100644 index 00000000000..54b1bf5aae2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/client.go @@ -0,0 +1,26 @@ +package supportedoperatingsystems + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOperatingSystemsClient struct { + Client *resourcemanager.Client +} + +func NewSupportedOperatingSystemsClientWithBaseURI(sdkApi sdkEnv.Api) (*SupportedOperatingSystemsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "supportedoperatingsystems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SupportedOperatingSystemsClient: %+v", err) + } + + return &SupportedOperatingSystemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/id_vault.go new file mode 100644 index 00000000000..52547b6c405 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/id_vault.go @@ -0,0 +1,125 @@ +package supportedoperatingsystems + +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/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/id_vault_test.go new file mode 100644 index 00000000000..30de91cab81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/id_vault_test.go @@ -0,0 +1,282 @@ +package supportedoperatingsystems + +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/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/method_get.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/method_get.go new file mode 100644 index 00000000000..682ce9fa220 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/method_get.go @@ -0,0 +1,80 @@ +package supportedoperatingsystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SupportedOperatingSystems +} + +type GetOperationOptions struct { + InstanceType *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InstanceType != nil { + out.Append("instanceType", fmt.Sprintf("%v", *o.InstanceType)) + } + return &out +} + +// Get ... +func (c SupportedOperatingSystemsClient) Get(ctx context.Context, id VaultId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationSupportedOperatingSystems", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_osversionwrapper.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_osversionwrapper.go new file mode 100644 index 00000000000..af334b23ea8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_osversionwrapper.go @@ -0,0 +1,9 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSVersionWrapper struct { + ServicePack *string `json:"servicePack,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedoperatingsystems.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedoperatingsystems.go new file mode 100644 index 00000000000..2d7bee64192 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedoperatingsystems.go @@ -0,0 +1,12 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOperatingSystems struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SupportedOSProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosdetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosdetails.go new file mode 100644 index 00000000000..b89ec6cfe3a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosdetails.go @@ -0,0 +1,10 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSDetails struct { + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersions *[]OSVersionWrapper `json:"osVersions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosproperties.go new file mode 100644 index 00000000000..ee9acfc9a81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosproperties.go @@ -0,0 +1,8 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSProperties struct { + SupportedOsList *[]SupportedOSProperty `json:"supportedOsList,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosproperty.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosproperty.go new file mode 100644 index 00000000000..e9f60b43c0b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/model_supportedosproperty.go @@ -0,0 +1,9 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSProperty struct { + InstanceType *string `json:"instanceType,omitempty"` + SupportedOs *[]SupportedOSDetails `json:"supportedOs,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/version.go new file mode 100644 index 00000000000..d13016ce87f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/supportedoperatingsystems/version.go @@ -0,0 +1,12 @@ +package supportedoperatingsystems + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/supportedoperatingsystems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/README.md b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/README.md new file mode 100644 index 00000000000..a1901d41871 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes` Documentation + +The `targetcomputesizes` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicessiterecovery` (API Version `2023-08-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/recoveryservicessiterecovery/2023-08-01/targetcomputesizes" +``` + + +### Client Initialization + +```go +client := targetcomputesizes.NewTargetComputeSizesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TargetComputeSizesClient.ListByReplicationProtectedItems` + +```go +ctx := context.TODO() +id := targetcomputesizes.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + +// alternatively `client.ListByReplicationProtectedItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectedItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/client.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/client.go new file mode 100644 index 00000000000..50f60300d6a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/client.go @@ -0,0 +1,26 @@ +package targetcomputesizes + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSizesClient struct { + Client *resourcemanager.Client +} + +func NewTargetComputeSizesClientWithBaseURI(sdkApi sdkEnv.Api) (*TargetComputeSizesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "targetcomputesizes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TargetComputeSizesClient: %+v", err) + } + + return &TargetComputeSizesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/id_replicationprotecteditem.go new file mode 100644 index 00000000000..63133c588db --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/id_replicationprotecteditem.go @@ -0,0 +1,152 @@ +package targetcomputesizes + +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 = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) 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.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(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 := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricValue"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerValue"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemValue"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..de78df399d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/id_replicationprotecteditem_test.go @@ -0,0 +1,417 @@ +package targetcomputesizes + +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 = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue") + + 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.ReplicationFabricName != "replicationFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricValue") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerValue") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemValue") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "replicationFabricValue", "replicationProtectionContainerValue", "replicationProtectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // 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/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectedItemName: "replicationProtectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // 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/replicationFabrics", + Error: 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/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems", + Error: 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + ReplicationFabricName: "replicationFabricValue", + ReplicationProtectionContainerName: "replicationProtectionContainerValue", + ReplicationProtectedItemName: "replicationProtectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/replicationFabrics/replicationFabricValue/replicationProtectionContainers/replicationProtectionContainerValue/replicationProtectedItems/replicationProtectedItemValue/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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcVaLuE", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMvAlUe", + }, + }, + { + // 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/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcVaLuE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRvAlUe/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(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.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId 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/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/method_listbyreplicationprotecteditems.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/method_listbyreplicationprotecteditems.go new file mode 100644 index 00000000000..5a372938b41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/method_listbyreplicationprotecteditems.go @@ -0,0 +1,91 @@ +package targetcomputesizes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectedItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TargetComputeSize +} + +type ListByReplicationProtectedItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TargetComputeSize +} + +// ListByReplicationProtectedItems ... +func (c TargetComputeSizesClient) ListByReplicationProtectedItems(ctx context.Context, id ReplicationProtectedItemId) (result ListByReplicationProtectedItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/targetComputeSizes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TargetComputeSize `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectedItemsComplete retrieves all the results into a single object +func (c TargetComputeSizesClient) ListByReplicationProtectedItemsComplete(ctx context.Context, id ReplicationProtectedItemId) (ListByReplicationProtectedItemsCompleteResult, error) { + return c.ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx, id, TargetComputeSizeOperationPredicate{}) +} + +// ListByReplicationProtectedItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TargetComputeSizesClient) ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectedItemId, predicate TargetComputeSizeOperationPredicate) (result ListByReplicationProtectedItemsCompleteResult, err error) { + items := make([]TargetComputeSize, 0) + + resp, err := c.ListByReplicationProtectedItems(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByReplicationProtectedItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_computesizeerrordetails.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_computesizeerrordetails.go new file mode 100644 index 00000000000..f16abf36733 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_computesizeerrordetails.go @@ -0,0 +1,9 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeSizeErrorDetails struct { + Message *string `json:"message,omitempty"` + Severity *string `json:"severity,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_targetcomputesize.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_targetcomputesize.go new file mode 100644 index 00000000000..532ef19b568 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_targetcomputesize.go @@ -0,0 +1,11 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSize struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TargetComputeSizeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_targetcomputesizeproperties.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_targetcomputesizeproperties.go new file mode 100644 index 00000000000..474a614fb31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/model_targetcomputesizeproperties.go @@ -0,0 +1,17 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSizeProperties struct { + CpuCoresCount *int64 `json:"cpuCoresCount,omitempty"` + Errors *[]ComputeSizeErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HighIopsSupported *string `json:"highIopsSupported,omitempty"` + HyperVGenerations *[]string `json:"hyperVGenerations,omitempty"` + MaxDataDiskCount *int64 `json:"maxDataDiskCount,omitempty"` + MaxNicsCount *int64 `json:"maxNicsCount,omitempty"` + MemoryInGB *float64 `json:"memoryInGB,omitempty"` + Name *string `json:"name,omitempty"` + VCPUsAvailable *int64 `json:"vCPUsAvailable,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/predicates.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/predicates.go new file mode 100644 index 00000000000..e884ca4906e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/predicates.go @@ -0,0 +1,27 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSizeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p TargetComputeSizeOperationPredicate) Matches(input TargetComputeSize) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/version.go b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/version.go new file mode 100644 index 00000000000..4ef7ac7505e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2023-08-01/targetcomputesizes/version.go @@ -0,0 +1,12 @@ +package targetcomputesizes + +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 = "2023-08-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/targetcomputesizes/%s", defaultApiVersion) +}